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!

Switchboard Button to Run a Report 1

Status
Not open for further replies.

SherryLynn

Technical User
Feb 4, 2001
171
CA
Hello,

I am hoping someone can help me out. I am looking to add a button to my Switchboard to run a label report. Now here's the hard part (at least for me :) ).

To get the info for this report I have to run a make table query to get the info from particular records (there are parameters set up to meet certain criteria). Once I have this table, another query is run on this table which pieces some information together into a couple of columns. Then I have a label report which uses this query as it's source. How do I program a button on my switchboard to run all of this at once instead of doing two separate actions? I am not very experienced with coding. Thanks very much.

Sherry
 
Thank you Bob!

This was the perfect solution! I added the code and it runs exactly how I want it to.

Sherry
 
My apologies for taking you on such an wild goose chase. After re-reading the initial thread it was apparent to me that everything was working correctly and you just wanted to execute it from behind a button. However, I spotted what i though was a slight design flaw in your function and . . . wee, we won't get into that fiasco will we.

Thanks for the star and good luck with your project.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Hi Bob,

I have a small problem. The command button works great on the form, but I'm having trouble getting it on my Switchboard. If I use the Switchboard manager to add a button it has an option to Run procedure, but I'm not sure where to go from there? Do I need to create a module? If I try to add a "command button" to the switchboard, the button just appears on each page of the switchboard instead of on the appropriate page. I don't know if I'm making any sense here.

Thanks, and don't worry about the "goose chase" :)

Sherry
 
Hi Bob,

I created this module, will this work? When I called this function off the switchboard button I got this error.

"There was an error executing the command"

Option Compare Database
Option Explicit

Function LabelReport()

DoCmd.SetWarnings False
DoCmd.OpenQuery "queLabels-Export-Date"
DoCmd.OpenReport "Labels-Date"
DoCmd.SetWarnings True

End Function

Sherry
 
I don't see anything wrong with it other than you might want to make a Public declaration of the Function.

Code:
Public Function LabelReport()

What line is the code stopping on. Is it the actual call from your button?

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Hi Bob,

It's the call from the button I belive. It doesn't come up with a debug message. When I run the code it works fine (I can't believe I did that right :) ).

When I go to the switchboard manager I type the text I want on the button, under Command I choose Run Code, under Function Name I type LabelReport. Doesn't that seem right? I checked my spelling?

Thanks again.
 
Try putting the open/close paraenthesis behind the function name or use the Builder Button to the right of the line and pick your function and let ACCESS fill it in for you. That is the safest way.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Hi Bob,

I tried adding the parenthesis, but I still get the error.

In the SW manager, where I type in the name of the function, there is no builder button, or drop down list. If I chose Run Macro, there is a drop down list of my macros (I kind of expected it would be the same for Run Code).

I tried to run this with a Macro, but it's sloppy and I have to go through all the screens confirming that I want to run the maketable, erase the existing, etc., etc.

I'm at a loss as to why I would get that error. Have you ever run code from a switchboard button? Does it usually work?

Sherry
 
To tell you the truth I don't ever use the Switchboard menu. I build custom menus and write VBA code behind each button. If your menu is not too complex you could try that.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Just for you , I created a new switchboard with a function just as we described above with a report being printed. I added a new item to the switchboard that calls the function by just selecting Run Code and typing in the Function Name.

Everything works just fine. Runs the code to call the report. No Errors. Check spelling as it must be exact.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Hi Bob,

I sure appreciate all your efforts and patience here. I tried to make a new item and still the same error. It should be really simple - it must be something in my program or something. I guess I'll just keep trying to fiddle around with it or try those menus you suggested. Thanks for your help.

Sherry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top