Waubain
11-13-2010, 09:33 AM
I am trying to pass the Access Code from the Login from to the Main form in a variable called User. The plan is when the user adds a new record in the Main form the User value is added to a control source in Main table field named strUser. Here is the part of the code. Thank you.
'frmLogIn Form Code
'Check value of password in tblUser to see if matches
If Me.txtVerifyCode.Value = DLookup("VerifyCode", "tblUsers", "AccessCode='" & Me.txtAccessCode.Value & "'") Then
lngMyEmpID = Me.txtAccessCode.Value
'Close logon form and open main form screen, carries User to Main form
DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmMain", acNormal, , , , acWindowNormal, "txtAccessCode.Value"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtAccessCode.SetFocus
End If
'frmMain Code
Private Sub Form_Open(Cancel As Integer)
Dim User As String
User = CString(Me.OpenArgs)
Refresh
End Sub
'frmLogIn Form Code
'Check value of password in tblUser to see if matches
If Me.txtVerifyCode.Value = DLookup("VerifyCode", "tblUsers", "AccessCode='" & Me.txtAccessCode.Value & "'") Then
lngMyEmpID = Me.txtAccessCode.Value
'Close logon form and open main form screen, carries User to Main form
DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmMain", acNormal, , , , acWindowNormal, "txtAccessCode.Value"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtAccessCode.SetFocus
End If
'frmMain Code
Private Sub Form_Open(Cancel As Integer)
Dim User As String
User = CString(Me.OpenArgs)
Refresh
End Sub