K
Kevin
Hi,
I have a form with locked fields. In order to select individual records for
194 countries I use a combo box. To update this form I use another form with
unlocked fields which is opened with a command button with a Macro behind it.
I also use the follwing expression to filter this Edit form:
[ctbto table 1]![country]=[Forms]![experimental_form1]![country]
This all works fine, but I wanted to add a password to the command button
which opens the Edit form to restrict users' ability to edit the form. I
found the following code which creates a password function:
Private Sub Command354_Click()
'Attached to On Click event of cmdOpenEmpForm
Dim strPasswd
strPasswd = InputBox("Enter Password", "Restricted Form")
'Check to see if there is any entry made to input box, or if
'cancel button is pressed. If no entry made then exit sub.
If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Sub
End If
'If correct password is entered open Edit form
'If incorrect password entered give message and exit sub
If strPasswd = "graham" Then
DoCmd.OpenForm "Edit Quick info", acNormal
Me.Filter = "country = '" & Me.Combo20 & "'"
Me.FilterOn = True
Else
MsgBox "Sorry, you do not have access to this form", _
vbOKOnly, "Important Information"
Exit Sub
End If
End Sub
My question is: what code can I add to filter the Edit form? I've found that
I have to remove the Macro hwich also removes the filter. I've tried using
"Me.Filter..." as shown above, but without success. What can I do?
Thanks much in advance.
I have a form with locked fields. In order to select individual records for
194 countries I use a combo box. To update this form I use another form with
unlocked fields which is opened with a command button with a Macro behind it.
I also use the follwing expression to filter this Edit form:
[ctbto table 1]![country]=[Forms]![experimental_form1]![country]
This all works fine, but I wanted to add a password to the command button
which opens the Edit form to restrict users' ability to edit the form. I
found the following code which creates a password function:
Private Sub Command354_Click()
'Attached to On Click event of cmdOpenEmpForm
Dim strPasswd
strPasswd = InputBox("Enter Password", "Restricted Form")
'Check to see if there is any entry made to input box, or if
'cancel button is pressed. If no entry made then exit sub.
If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Sub
End If
'If correct password is entered open Edit form
'If incorrect password entered give message and exit sub
If strPasswd = "graham" Then
DoCmd.OpenForm "Edit Quick info", acNormal
Me.Filter = "country = '" & Me.Combo20 & "'"
Me.FilterOn = True
Else
MsgBox "Sorry, you do not have access to this form", _
vbOKOnly, "Important Information"
Exit Sub
End If
End Sub
My question is: what code can I add to filter the Edit form? I've found that
I have to remove the Macro hwich also removes the filter. I've tried using
"Me.Filter..." as shown above, but without success. What can I do?
Thanks much in advance.