Please help with code???

crann

Registered User.
Local time
Today, 10:45
Joined
Nov 23, 2002
Messages
160
Hi,

I am trying to protect a command button that currently opens a standard mailing list form.

I have read through other Threads, but am new to code, i am using this code to password protect the button:

If InputBox ("Please enter your password.","Password Checkpoint") = "make_up_a_password_to_fill_in_this_space" Then
Do_this_appropriate_action
Else
Invalid_password_action
Exit Sub
End If

I am inserting the above code on the buttons 'on click' event procedure, but there is also the code (below) to open the form, in there and i don't know how the code should read, so that first it asks for a password then if correct opens the form.


Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Mailing List"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

If i insert the code that opens the form in the code above where it says 'do this appropriate action, i get all sorts of compile errors, God knows what i am doing.


Hope someone can understand this. Its blinking confusing.

Thanks Guys.....
 
Try this:

Private Sub Command0_Click()

If InputBox ("Please enter your password.","Password Checkpoint") = "make_up_a_password_to_fill_in_this_space" Then
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Mailing List"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

Else
Invalid_password_action
Exit Sub
End If
End Sub


Hope this works for you.

edtab
 

Users who are viewing this thread

Back
Top Bottom