password program

A

Afrosheen

Could someone please look at this and tell me what is wrong.
What I'm trying to do is once I click on a text box in the main menu I want
it to trigger the password form. Once the information is checked and verified
then it will go back to the main menu and unload the forms so I can get to
the programs.
What it is doing is once the text box is pressed then the password form
comes up then returns to the main menu. It does not stop to ask the questions.

This is the code for the textbox click:

Private Sub svt01_Click()
Dim stdocname As String
strdocname = "frmpass"

DoCmd.OpenForm strdocname, acNormal
MsgBox "it is not working"
'DoCmd.Close acForm, "frmpass" 'Closes the password window
DoCmd.Close

Dim I As Integer
For I = 1 To CommandBars.Count
CommandBars(I).Enabled = True
Next I


DoCmd.SelectObject acTable, , True
End Sub

This is the code for the password form

Private Sub Pword_AfterUpdate()
Dim strUser As String
strUser = username
MsgBox "im waiting"
If StrComp(Me.Pword, Nz(DLookup("Password", "tblpass", "User=" & """" &
strUser & """"), ""), 0) = 0 Then
MsgBox "hi there. Your In."
strUser = ""
username = ""
Pword = ""
Exit Sub
Else
Call MsgBox("Oh Oh!! You Didn't Say The Magic Word!!", vbCritical,
Application.Name)
strUser = ""
username = ""
Pword = ""
End If

End Sub

In the password form I have two text boxes. One called User and the other is
Password.

Thanks for reading this.
 
M

Mark Ransom

The trick here is to open frmpass as modal. This will halt your code in
the calling routine until you close frmpass, so you can either proceed
or terminate based on the input from the user
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top