Adding code to a custom menu button

G

Guest

I have been reading the posts about how to use the Print Dialog box and
everything I've read says to add code to my menu buttons. I'm pretty new at
using code, so I'm not sure how/where to do this.

I have already created the custom menu and want to have the Print Dialog box
display when the user clicks the menu button. I have seen the code

On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint

posted on this site, but I don't know where to put it. I have tried
creating a macro that runs when the button is selected, but it doesn't seem
to be working. Am I going about this all wrong? Please help!! Thank you!!
 
C

Carl Rapson

Sarah0824 said:
I have been reading the posts about how to use the Print Dialog box and
everything I've read says to add code to my menu buttons. I'm pretty new
at
using code, so I'm not sure how/where to do this.

I have already created the custom menu and want to have the Print Dialog
box
display when the user clicks the menu button. I have seen the code

On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint

posted on this site, but I don't know where to put it. I have tried
creating a macro that runs when the button is selected, but it doesn't
seem
to be working. Am I going about this all wrong? Please help!! Thank
you!!

Put the code in the Click event of the button. Open your form in design
view, select the button, and open its Properties window. On the Event tab
next to On Click, select [Event Procedure] in the combo box and then click
on the small button next to the combo box (the one with three dots in it).
This will open the form's code window with the button's Click event already
started for you. All you need to do is add your code between the Private Sub
and End Sub lines. Close the code window, save and close the form, and test
your form.

Carl Rapson
 
G

Guest

Thanks. Sorry for any confusion. The button is not on a form. It is in the
menu bar on a custom menu that I created. I need to use it for a report.
Does that clarify it any better?

Carl Rapson said:
Sarah0824 said:
I have been reading the posts about how to use the Print Dialog box and
everything I've read says to add code to my menu buttons. I'm pretty new
at
using code, so I'm not sure how/where to do this.

I have already created the custom menu and want to have the Print Dialog
box
display when the user clicks the menu button. I have seen the code

On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint

posted on this site, but I don't know where to put it. I have tried
creating a macro that runs when the button is selected, but it doesn't
seem
to be working. Am I going about this all wrong? Please help!! Thank
you!!

Put the code in the Click event of the button. Open your form in design
view, select the button, and open its Properties window. On the Event tab
next to On Click, select [Event Procedure] in the combo box and then click
on the small button next to the combo box (the one with three dots in it).
This will open the form's code window with the button's Click event already
started for you. All you need to do is add your code between the Private Sub
and End Sub lines. Close the code window, save and close the form, and test
your form.

Carl Rapson
 
C

Carl Rapson

Sarah0824 said:
Thanks. Sorry for any confusion. The button is not on a form. It is in
the
menu bar on a custom menu that I created. I need to use it for a report.
Does that clarify it any better?

Carl Rapson said:
Sarah0824 said:
I have been reading the posts about how to use the Print Dialog box and
everything I've read says to add code to my menu buttons. I'm pretty
new
at
using code, so I'm not sure how/where to do this.

I have already created the custom menu and want to have the Print
Dialog
box
display when the user clicks the menu button. I have seen the code

On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint

posted on this site, but I don't know where to put it. I have tried
creating a macro that runs when the button is selected, but it doesn't
seem
to be working. Am I going about this all wrong? Please help!! Thank
you!!

Put the code in the Click event of the button. Open your form in design
view, select the button, and open its Properties window. On the Event tab
next to On Click, select [Event Procedure] in the combo box and then
click
on the small button next to the combo box (the one with three dots in
it).
This will open the form's code window with the button's Click event
already
started for you. All you need to do is add your code between the Private
Sub
and End Sub lines. Close the code window, save and close the form, and
test
your form.

Carl Rapson

Sorry, I missed that part. Unfortunately I don't use custom menus so I don't
think I can give much help. Perhaps someone else who has experience with
custom menus could jump in here.

Carl Rapson
 
G

Guest

Sarah,

I'll give it a shot. Try the following:

1. You have the menubar already made. If not create one by choosing
customize from the toolbar options. Choose new and give it an appropriate
name.
2. Your toolbar should be visible now
3. Go to the file menu and open it (while still in customize mode)
4. Now keep the ctrl-key pressed and drag the print option button to your
own toolbar. This should create a replica of the print dialog option in your
own toolbar.
5. Close the customize toolbar option
6. Open your report in designview
7. Go to the properties -> Toolbar
8. choose the name of your toolbar here. This will display your toolbar when
opening your report. You can designate this toolbar to any place you'd like
this way (also forms etc.)

note: when you are in prview mode of the report the printdialog option is
already there so i'm kind of curious as to why you would want to create your
own button.

Hope I understood the question right. If not post what I didn't get and i'll
try again.
 
G

Guest

I hope you get this response. I never got a notification that any other
responses had been posted. I had come up with something that seemed to be
working, but then it started to present other problems, and I came back here
to search for another solution. I saw your post and tried it and it worked
awesome!!! I struggled with this forever! Who knew it could be so easy??

Thanks for all your help!!

Oh, and to answer your question...we created a custom File menu to limit
what the users can do...they are VERY computer illiterate and we needed to
make it very "babyproof" so we just gave them what we needed. Thanks again.
You are a lifesaver!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top