Please pardon me if this message gets posted twice, but I tried to post it last night and now I cannot find it today. I probably did something wrong.
I have a login form that I am attempting to store the userid value when a user logs in to my database. I have created a form and a table to store users and their passwords. On my form I created a macro using the SetTempVar() function on an AfterUpdate event
for a text field.. I am new to Access programming and would like to see what my variables are either through debugging or by displaying a message box with the value stored in the variable. I have struggled through with immediate windows and the value seems
to be null. I have attached some code below, but basically I want to store the value stored in my TempVar variable into a record when the AfterUpdate event occurs for all of my other forms. Please review my code and let me know where I am going wrong or
if you have any suggestions. Thanks in advance.
Option Compare Database 'Use database order for string comparisons
Option Explicit
Dim dum As String
Private Sub cmdLogin_Click()
dum = ProcessPassword()
End Sub
Function ProcessPassword()
Dim strWhere, strWhere2 As String
Dim varname As Variant
If IsNull(Me.txtUserName) Or IsNull(Me.txtPassword) Then
MsgBox "You must enter a user name and password."
Else
strWhere = "uCode = '" & Me.txtUserName & "' AND " & "uPassword = '" & Me.txtPassword & "'"
varname = DLookup("[uCode] & ' ' & [uPassword]", "tblUsers", strWhere)
Debug.Print TempVars("tmpUserID")
If IsNull(varname) = True Then
MsgBox "Incorrect UserName or Password, try again!", 48, "Login Error"
Me!txtPassword = ""
Me!txtPassword.SetFocus
Else
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmSystemInfo"
End If
End If
End Function