Hello folks,
I need your help.
I have two forms, frmProjts1 and frmPassword.
frmProjts1 has a combo box called "cbBox1" and it's ‘row source type’ property set to Value List and ‘Row Source’ property is filled with Value1";"Value2";"Value3";"Value4"
What I am trying to do is when the frmProjts1 is open the user can select a value from cboBox1. If the user selects 'Value4' then it will open the password form "frmPassword" and the user should enter the password and clik OK button. If the password matches with the password field of tblPassword then it will close frmPassword and the focus is back to the control cboBox1/frmProjts1.
If the password is invalid then it should issue a msg, close the frmPassword and the focus transfers back to cboBox1 of frmProjts1 and should set the cboBox1 value to the value which was assigned when the frmProjts1 is first open. That is, if the value was Value2 before and if the user wants to set it to Value4 then if the password is wrong then the cboBox1 value should revert back to Value2.
My DLookup function issues an run-time error msg like “data type mismatch in criteria expression”
Following is my two procedures:
Private Sub cboBox1_AfterUpdate()
Private Sub cmdOK_Click()
Any suggestion is greatly appreciated.
Thanks
Shan.
I need your help.
I have two forms, frmProjts1 and frmPassword.
frmProjts1 has a combo box called "cbBox1" and it's ‘row source type’ property set to Value List and ‘Row Source’ property is filled with Value1";"Value2";"Value3";"Value4"
What I am trying to do is when the frmProjts1 is open the user can select a value from cboBox1. If the user selects 'Value4' then it will open the password form "frmPassword" and the user should enter the password and clik OK button. If the password matches with the password field of tblPassword then it will close frmPassword and the focus is back to the control cboBox1/frmProjts1.
If the password is invalid then it should issue a msg, close the frmPassword and the focus transfers back to cboBox1 of frmProjts1 and should set the cboBox1 value to the value which was assigned when the frmProjts1 is first open. That is, if the value was Value2 before and if the user wants to set it to Value4 then if the password is wrong then the cboBox1 value should revert back to Value2.
My DLookup function issues an run-time error msg like “data type mismatch in criteria expression”
Following is my two procedures:
Private Sub cboBox1_AfterUpdate()
Dim strPassword As String
If Me.cboBox.Value = "Value4" Then
DoCmd.OpenForm "frmPassword"
End If
End SubIf Me.cboBox.Value = "Value4" Then
DoCmd.OpenForm "frmPassword"
End If
Private Sub cmdOK_Click()
Dim strPassword As String
strPassword = Me!txtPassword
'If strPassword = "2326" Then
'the following line doesn't work
If strPassword = DLookup("chrPassword", "tblPassword", "chrPassword = " & strPassword) Then
DoCmd.Close
Else
DoCmd.Close
MsgBox "You do not have permission to change this field"
Forms!frmProjts1!cboBox1.SetFocus
Forms!frmProjts1!cboBox1.Value = "?????" ' <-need your help here, don't know how to trap the original value
End If
End SubstrPassword = Me!txtPassword
'If strPassword = "2326" Then
'the following line doesn't work
If strPassword = DLookup("chrPassword", "tblPassword", "chrPassword = " & strPassword) Then
DoCmd.Close
Else
DoCmd.Close
MsgBox "You do not have permission to change this field"
Forms!frmProjts1!cboBox1.SetFocus
Forms!frmProjts1!cboBox1.Value = "?????" ' <-need your help here, don't know how to trap the original value
End If
Any suggestion is greatly appreciated.
Thanks
Shan.