Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement

Status
Not open for further replies.

vix666

IS-IT--Management
Jul 17, 2003
63
AU
I have this code and when i run it it comes up with a message "end if without block if", i'm new to if statements and not sure whats wrong.
Also the txt_box holds the value so when the form is opened, the password is still displayed which of course for a password isnt very appropriate. So any help would be appreciated :)

Private Sub Cmd_Enterpass_Click()

Dim strpass As String

strpass = txt_pass

If strpass = "ali" Then DoCmd.OpenForm "frmadmin"
DoCmd.Close
Exit Sub
End If

MsgBox "You do not have access", vbOKCancel
DoCmd.Close

End Sub
 
remove the exit sub under docmd.close and do you need the docmd.close in

Hope this helps
Hymn
 
Thanks for the help but i've removed the exit sub and its still coming up with the message.
I need to close the form when the other opens so i need the docmd.close.
Also how do you get the box to not keep the value?

Any other ideas?
 
what are you closing with the first docmd.close

Hope this helps
Hymn
 
You just made me realise i was trying to open the wrong form, but i still get the error message.

The first docmd.close is closing the password entry form, i also need it to close the form from where it was launched from - any ideas how you can do this?

Heres the changed code below

Private Sub Command5_Click()

Dim strpass As String

strpass = txt_pass

If strpass = "ali" Then DoCmd.OpenForm "Entry Form Admin"
DoCmd.Close
End If

MsgBox "You do not have access", vbOKCancel
DoCmd.Close

End Sub
 
try
Private Sub Command5_Click()

Dim strpass As String

strpass = txt_pass

If strpass = "ali" Then
DoCmd.OpenForm "Entry Form Admin"
DoCmd.Close "PasswordForm"
else
MsgBox "You do not have access", vbOKCancel
docmd.quit

End If

the docmd.quit is severe but it stops people playing


Hope this helps
Hymn
 
Thanks for all your help :)
I agree quitting the application will result in people not playing as they like to do here!

Thanks again

Vicky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top