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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon form not closing after Password Authentictated

Status
Not open for further replies.

noonan1

Technical User
Joined
Feb 20, 2003
Messages
10
Location
IE
I have a logon form that checks user id and password, once you click the login button a new form should open called "frmWelcome" and the "logon" form should close.The problem is that when a users password is authenticated the welcome form opens but the logon form does not close behind it. I would appreciate any suggestions as to how to overcome this problem.I will attach the code causing the problems, thank you in advance.

'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", _
"tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value

'Close logon form and open welcome screen

DoCmd.Close acForm, "Logon", acSaveNo
DoCmd.OpenForm "frmWelcome"




Else
MsgBox "Password Invalid. Please Try Again", _
vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
 
Try changing:
DoCmd.Close acForm, "Logon", acSaveNo
to
DoCmd.Close acForm, Me.Name, acSaveNo

You may have misspelled the name...

Good luck
[pipe]
Daniel Vlas
Systems Consultant
 
Is your Logon form actually called "Logon", maybe "frmLogon" or something else, it's just that there is nothing wrong with your Close Method, though this is all you need to close the active form:

DoCmd.Close

Nothing wrong with your suggestion danvlas, it works well, just don't like unsolved mysteries.


 
[lol]
(I mentioned misspelling the name as a strong possibility)
DoCmd.Close indeed closes the active form, but how can you tell which is that, especially in a long sequence of code? You may toggle some visibility, activate one form, close another and therefore I try to use this Me.Name thing as often as I can (except for my moments of laziness)

[2thumbsup]

[pipe]
Daniel Vlas
Systems Consultant
 
Sorry danvlas,

I was just glanced your code then pointed out that DoCmd.Close would do in this case, it's behind a button on the Form noonan1 wants to close, the focus couldn't be anywhere else at that time in the example above. Please excuse my pedantry.
 
When I placed the DoCmd.Close line in the code, I got the following error message "The action cant be carried out while processing a form or report event".
The reason for this may be that when the user logs on they must select a department(from a field also on the log on form) and based on their department some forms that are also in the program, are visible to the user and others are not based on the department they selected, is there any way to workaround this fact and still close the form.Thanks again for all of your prompt and helpful responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top