Button on a Form

  • Thread starter Thread starter Clayton
  • Start date Start date
C

Clayton

Hi,
*** Using Office 95 Pro.

I'd like (easily?) to be able to put a button on some
forms, that would allow the user to click and return to
the Main Menu (switchboard). Is this possible?

Is there a GOOD site for tips and tricks for Access?

Please feel free to respond to my e-ddress

Thanks
Clayton
P.S. Yes, I am quite new to Access--sorry.
 
Clayton said:
Hi,
*** Using Office 95 Pro.

I'd like (easily?) to be able to put a button on some
forms, that would allow the user to click and return to
the Main Menu (switchboard). Is this possible?

Is there a GOOD site for tips and tricks for Access?

Please feel free to respond to my e-ddress

Thanks
Clayton
P.S. Yes, I am quite new to Access--sorry.

Use the command button wizard to create a button to open a form -- in
this case, the Switchboard form. It'll create code that looks something
like this:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim stLinkCriteria As String

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

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

I interpret your question to mean that you want the button also to close
the current form as the switchboard is opened. To do that, edit the
code for the button and add one more line, as shown below:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Switchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, Me.Name '<=== ADD THIS LINE

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub
 
-----Original Message-----


Use the command button wizard to create a button to open a form -- in
this case, the Switchboard form. It'll create code that looks something
like this:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim stLinkCriteria As String

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

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

I interpret your question to mean that you want the button also to close
the current form as the switchboard is opened. To do that, edit the
code for the button and add one more line, as shown below:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Switchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, Me.Name '<=== ADD THIS LINE

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Hope this is what you mean by Replying to the newsgroup.

Your Reply was most helpful. However, I guess even the
Command Buttons are somewhat limited? When I used the
wizard, and added your extra line for cloing the form, it
worked......almost like I wanted it to. The form closed,
and it went back to a previous menu, but not to the Main
menu (switchboard). I am making one selction that opens
up another menu, and from there to the selcted form, for
data entry.
I need to be able to (and I neglected to mention this
previously) with one button go back to the previous Menu,
and with a different button go back to the Main Menu.
I realize there are drop-down lists, but I haven't used
them--ever.

Other than the library (?) would there be an "Access for
Dummies" kind of book that you could suggest? I have two
books for Office 97, and both have been helpful, but not
very complete for any one program--kinda generic.

Thanks again
Clayton
 
Clayton said:
Hope this is what you mean by Replying to the newsgroup.
Yep.


Your Reply was most helpful. However, I guess even the
Command Buttons are somewhat limited? When I used the
wizard, and added your extra line for cloing the form, it
worked......almost like I wanted it to. The form closed,
and it went back to a previous menu, but not to the Main
menu (switchboard). I am making one selction that opens
up another menu, and from there to the selcted form, for
data entry.
I need to be able to (and I neglected to mention this
previously) with one button go back to the previous Menu,
and with a different button go back to the Main Menu.
I realize there are drop-down lists, but I haven't used
them--ever.

Ah, okay, I see what's going on. The form you want to go back to is a
switchboard that was created by the Switchboard Manager. The problem is
complicated by the fact that the same form is used to display both sets
of switchboard items. Which menu is displayed depends on the filter
that has been applied to the form.

I don't normally use the Swithcboard Manager, so I'm not intimately
familiar with its ins and outs, but I think you could make that form
display the main (or default) menu by adding a few more lines to the
code:

' ... same first part of code ...

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

With Forms!Switchboard
.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
.FilterOn = True
End With

' ... same last part of code ...

Try that code on the button that is supposed to go back the main menu.
Other than the library (?) would there be an "Access for
Dummies" kind of book that you could suggest? I have two
books for Office 97, and both have been helpful, but not
very complete for any one program--kinda generic.

Several good books have been suggested in the past, but I'm not familiar
with them myself and can't recall the titles offhand. If you use Google
Groups (http://groups.google.com) to search groups *.*access.* for "book
recommendations" -- or other keywords that might occur to you -- I'm
sure you'll find lots of articles with recommendations, and you can use
your own judgement.
 
-----Original Message-----
Hope this is what you mean by Replying to the
newsgroup.
Yep.


Your Reply was most helpful. However, I guess even the
Command Buttons are somewhat limited? When I used the
wizard, and added your extra line for cloing the form, it
worked......almost like I wanted it to. The form closed,
and it went back to a previous menu, but not to the Main
menu (switchboard). I am making one selction that opens
up another menu, and from there to the selcted form, for
data entry.
I need to be able to (and I neglected to mention this
previously) with one button go back to the previous Menu,
and with a different button go back to the Main Menu.
I realize there are drop-down lists, but I haven't used
them--ever.

Ah, okay, I see what's going on. The form you want to go back to is a
switchboard that was created by the Switchboard Manager. The problem is
complicated by the fact that the same form is used to display both sets
of switchboard items. Which menu is displayed depends on the filter
that has been applied to the form.

I don't normally use the Swithcboard Manager, so I'm not intimately
familiar with its ins and outs, but I think you could make that form
display the main (or default) menu by adding a few more lines to the
code:

' ... same first part of code ...

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

With Forms!Switchboard
.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
.FilterOn = True
End With

' ... same last part of code ...

Try that code on the button that is supposed to go back the main menu.
Other than the library (?) would there be an "Access for
Dummies" kind of book that you could suggest? I have two
books for Office 97, and both have been helpful, but not
very complete for any one program--kinda generic.

Several good books have been suggested in the past, but I'm not familiar
with them myself and can't recall the titles offhand. If you use Google
Groups (http://groups.google.com) to search groups *.*access.* for "book
recommendations" -- or other keywords that might occur to you -- I'm
sure you'll find lots of articles with recommendations, and you can use
your own judgement.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Ok, I'll try that code. Now, I'm going to post a new
topic.
Thanks much for your help. I'll look forward
to "tapping" your knowledge on this next post.
Clayton
 
Back
Top