need help with form opening/closing code

scary1

Registered User.
Local time
Today, 08:04
Joined
Feb 25, 2003
Messages
20
Bear with me guys cause as you can tell i am a novice with this!
OK I have an entry form with 2 buttons. One button has apassword as its restricted to certain staff only. When the button is pressed and the staff enters the correct password I want the form to close and the "access window" be viewable so they can go into tables, queries, whatever they want.
This is so other staff cant go in and mess about-i was asked to specifically set it up this way as well!
So here is the code i have so far:Private Sub Command14_Click()
'attached to On Click event of cmdOpenEmpForm

Dim strPasswd

strPasswd = InputBox("Please enter password", "Restricted Information")

'Check to see if there is amy entry made to input box of if
'cancel button is pressed.If no entry made then end sub.

If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No password entered", vbInformation, "Required Information"
Exit Sub
End If

'If correct password is entered open Employees form
'If incorrect password entered gice message and exit sub

If strPasswd = "lisa" Then
DoCmd.OpenForm "entry", acNormal
Else
MsgBox "Sorry you do not have access to this area", vbOKOnly, "Important Information!"
Exit Sub
End If
End Sub

So if they get wrong password they get message but I am not sure of the code to add to simply close the form if they get it right.

What a waffler!!! Can anyone help???
 
In the first part of your post you said you wanted to close the form and give access to the db window but in the true part of your code you have:

Code:
DoCmd.OpenForm "entry", acNormal


Should you just replace this with:

Code:
doCmd.Close

???
ken
 
silly me

oops sorry i should have missed that bit out. I did originally want to open another form but now have decided db window fine.
will try that and see!
 
it works

Thanks v much

Its official - I'm thick!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
x
 

Users who are viewing this thread

Back
Top Bottom