buttons

redandblack

Registered User.
Local time
Today, 11:36
Joined
Feb 10, 2005
Messages
33
i have constructed a switchboard/main menu and have set up buttons which link to forms. i have also made a 'return to main menu' button which does as it says, the only problem is that after going back to thge main menu both forms are now open...any ideas on how to stop this problem
 
Last edited:
redandblack said:
i have constructed a switchboard/main menu and have set up buttons which link to forms. i have also made a 'return to main menu' button which does as it says, the only problem is that after going back to thge main menu both forms are now open...any ideas on how to stop this problem
can't you just say on the button click


me.visible = false
and it will hide the form, it will still be open just hidden

I would recomend just a
docmd.close
first thing when you click the button and use your existing code to open the form you want
 
right click on the button in design view, goto properties, select the event tab, go to on click... it should already say "Event Procedure", click the ... to the right of the row. That will take you into the vba editor.

If you used the wizard to make this button you will see

Private Sub ______Click()
On Error GoTo Err_Command165_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "______"
DoCmd.OpenForm ______, , , stLinkCriteria

Exit________Click:
Exit Sub

Err_______Click:
MsgBox Err.Description
Resume Exit_______Click

End Sub


-----------------------Change to-----------

Private Sub ______Click()
docmd.close
On Error GoTo Err_Command165_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "______"
DoCmd.OpenForm ______, , , stLinkCriteria

Exit________Click:
Exit Sub

Err_______Click:
MsgBox Err.Description
Resume Exit_______Click

End Sub



That should get you started. There are always many ways to do the same thing, this is one that should work for you.
 
right that all works brilliantly except when i hit the button the msg 'the action or method requires a Form Name argument'

any ideas?? were so close to cracking this!! :D
 
Try this...
Code:
Private Sub btnReturnToMainMenu_Click()
On Error GoTo Err_btnReturnToMainMenu_Click

    DoCmd.OpenForm "frmMainMenu" 'open your main menu form
    DoCmd.Close acForm, Me.Name 'close the opened form that this code is run from

Exit_btnReturnToMainMenu_Click:
    Exit Sub

Err_btnReturnToMainMenu_Click:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_btnReturnToMainMenu_Click

End Sub
 
god knows what that last ones all about


still getting the error message..pelase help
 
Matrix_zero said:
right click on the button in design view, goto properties, select the event tab, go to on click... it should already say "Event Procedure", click the ... to the right of the row. That will take you into the vba editor.

If you used the wizard to make this button you will see

Private Sub ______Click()
On Error GoTo Err_Command165_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "______"
DoCmd.OpenForm ______, , , stLinkCriteria

Exit________Click:
Exit Sub

Err_______Click:
MsgBox Err.Description
Resume Exit_______Click

End Sub


-----------------------Change to-----------

Private Sub ______Click()
docmd.close
On Error GoTo Err_Command165_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "______"
DoCmd.OpenForm ______, , , stLinkCriteria

Exit________Click:
Exit Sub

Err_______Click:
MsgBox Err.Description
Resume Exit_______Click

End Sub



That should get you started. There are always many ways to do the same thing, this is one that should work for you.



when i hit the button the msg 'the action or method requires a Form Name argument' appears...

any ideas on how to get rid of this?? were so close to cracking this!!
 
Did you try the code I posted above? It works if you place it in the OnClick event of your command button. All you have to do is insert your forms name.
Code:
    DoCmd.OpenForm "YourFormNameHere"
    DoCmd.Close acForm, Me.Name
 
Forgot about the code just do it all in a Macro, a lot easier.

Right click the command button, open up properties, Event tab, On Click (make sure it is blank) click on the ..., choose Macro Builder.

Give your Macro a name.

Action Column - use the drop down to select Close, then on the Object Type (bottom of screen), use the drop down and select Form, then for Object Name use the drop down and select Form name you want to close.

Next Action column field, use dropdown to get OpenForm, choose the form to open.

Keep it simple!

Job Done
:)
 
coley said:
Forgot about the code just do it all in a Macro, a lot easier.

Right click the command button, open up properties, Event tab, On Click (make sure it is blank) click on the ..., choose Macro Builder.

Give your Macro a name.

Action Column - use the drop down to select Close, then on the Object Type (bottom of screen), use the drop down and select Form, then for Object Name use the drop down and select Form name you want to close.

Next Action column field, use dropdown to get OpenForm, choose the form to open.

Keep it simple!

Job Done
:)

That may be a simple solution for now as it's the easy way out but as soon as you see the posibilites with Access and VB you will soon wish that you had taken ghudson's advise.... ;)
 

Users who are viewing this thread

Back
Top Bottom