This is my first post, first attempt in coding in VBA and I appreciate any advice given.
Below is my coding for a login procedure accessing ODBC table called ROR_User that contains the user information (username, password, deptcode and role):
Private Sub Sign_On_Click()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim strSQL As String
rst.LockType = adLockReadOnly
Dim gdeptcode As String
Dim guser_role As String
'Retrieve matching login information from the ROR_User table
strSQL = "Select * FROM ROR_User WHERE [ROR_User].[User_ID]='" & Me.Username & "' AND [ROR_User].[Password]='" & Me.Userpassword & "'"
'Open our recordset to receive StrSQL (containing selected record)
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Not rst.EOF Then
guser_name = Me.Username
gpassword = Me.Userpassword
gdeptcode = Me.Deptcode
guser_role = Me.Role
DoCmd.OpenForm "Main Menu Processor", acNormal, "", "", acEdit, acNormal
DoCmd.OpenForm "Invalid Login (pop-up)", acNormal, "", "", acEdit, acNormal
The problem I am having are the following:
1. Where do I enter a close statement (rst.close) after I obtain the login information?
2. How do I clear out the login information entered on the form itself it has been entered?