form not closing onClick?

blanchard

Registered User.
Local time
Today, 20:03
Joined
Mar 24, 2009
Messages
39
Ok I've made lots of progress in Access over the last few weeks, but having a spot of trouble working out where I've gone wrong, I have a form with a button and on click I want that Form to clos and another form to open, but at the moment the form isn't closing.

I have a Form called "Contacts" and in the header section I have buttons
one of the buttons name is "Command48" and caption is "Log Out"

On the Command button properties option under the Event Tab
I selected [Event Procedure] to the side of On Click

then typed the following

Private Sub Command48_Click()
DoCmd.Close
DoCmd.OpenForm "Login"
End Sub

Regards
Blanchard
 
Ok I've made lots of progress in Access over the last few weeks, but having a spot of trouble working out where I've gone wrong, I have a form with a button and on click I want that Form to clos and another form to open, but at the moment the form isn't closing.

I have a Form called "Contacts" and in the header section I have buttons
one of the buttons name is "Command48" and caption is "Log Out"

On the Command button properties option under the Event Tab
I selected [Event Procedure] to the side of On Click

then typed the following

Private Sub Command48_Click()
DoCmd.Close
DoCmd.OpenForm "Login"
End Sub

Regards
Blanchard


The code looks good. Not sure why it wouldnt work
A suggestion would be to use the button wizard and then add your 2nd line of code.
 
That should be working for you. Do you have any code in any of the other form or object events?
 
Yes I also have a button located in the header part of the Contats form and the following code is attached to that and this works fine.

Private Sub ExitButton_Click()
DoCmd.Close
DoCmd.OpenForm "MainMenuScreen"
End Sub
 
What happens when you execute only the close command?
 
no i've just noticed that when i click to "log out" on the Contacts form the Contacts form closes but the Main Menu form opens and the log out screen both appear.
 
If you still are having the original problem in yout first post. Try This:
Private Sub ButtonNameClick()
DoCmd.Close acForm, "FormName"
DoCmd.OpenForm "FormName"
End Sub
 
Change your code to:
Code:
Private Sub Command48_Click()
   DoCmd.OpenForm "Login"   
   DoCmd.Close acForm, Me.Name, acSaveNo
   End Sub

Leave the line with the Me.Name part exactly as shown.
 
i don't need the log out button on that form i'll have it on the main menu screen instead as i don't think there will be need for two log out buttons.

thanks people...:)
 

Users who are viewing this thread

Back
Top Bottom