My form should do the following:
1)When user choose their id (Eg: S8745215G) from a combo-box(cboNRIC) and enter their name in a textbox(txtName).
2)The system check to see if the name entered matches the name stored in the table(PARTICULARS)
3)If name entered matches the name stored in the database, i would call out another form. But i need to pass the id into the form.
How should i do that?(Pass id into another form)
Now my problem is that i get the run-time error 2001, Please anyone help me..
Please tell me what's wrong. Thankyou.
--------------------------------------------------------------------------
The following is my code:
--------------------------------------------------------------------------
Option Compare Database
Private intLogonAttempts As Integer
'Check value of name in PARTICULARS to see if this matches value chosen in combo box
If Me.txtName.Value = DLookup("[NAME]", "PARTICULARS", "NRIC =" & Me.cboNRIC.Value)Then
lngMyEmpID = Me.cboNRIC.Value
DoCmd.Close acForm, "LOGIN_MENU", acSaveNo
DoCmd.OpenForm "ALL_INFORMATION_FORM_USER"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtName.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
1)When user choose their id (Eg: S8745215G) from a combo-box(cboNRIC) and enter their name in a textbox(txtName).
2)The system check to see if the name entered matches the name stored in the table(PARTICULARS)
3)If name entered matches the name stored in the database, i would call out another form. But i need to pass the id into the form.
How should i do that?(Pass id into another form)
Now my problem is that i get the run-time error 2001, Please anyone help me..
Please tell me what's wrong. Thankyou.
--------------------------------------------------------------------------
The following is my code:
--------------------------------------------------------------------------
Option Compare Database
Private intLogonAttempts As Integer
'Check value of name in PARTICULARS to see if this matches value chosen in combo box
If Me.txtName.Value = DLookup("[NAME]", "PARTICULARS", "NRIC =" & Me.cboNRIC.Value)Then
lngMyEmpID = Me.cboNRIC.Value
DoCmd.Close acForm, "LOGIN_MENU", acSaveNo
DoCmd.OpenForm "ALL_INFORMATION_FORM_USER"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtName.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Last edited: