Error running code from Switchboard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Below is my code in a module to run reports from a switchboard button. When
I try to run the reports, I get "There was an error executing the command"
error.

What am I doing wrong? TIA. Allan

Sub PrintAssignments()
On Error GoTo Err_PrintAssignments

Dim stDocName As String
Dim i As Integer

i = 1

Do Until i = 16
stDocName = "rptVA" & i
DoCmd.OpenReport stDocName, acNormal
i = i + 1
Loop
Exit Sub

Exit_PrintAssignments:
Exit Sub

Err_PrintAssignments:
MsgBox Err.Description
Resume Exit_PrintAssignments

End Sub
 
What line produces the error?

I'll bet this won't help, but you should probably change your statement to:
stDocName = "rptVA" & CStr(i)

Barry
 
Thanks for the response, Barry.

This code worked fine as an onclick event in a form, so I don't think there
is an error in the code itself.

I'm guessing the error is how I'm calling the module from the Switchboard --
using the Switchboard manager, I added a button, selected "Run Code" as the
command and put "PrintAssignments" in the function name box.

I can run the code from within VBA without a problem but cannot from the
switchboard (as already stated) or from the module window in Access.

Any other ideas on what I'm failing to do?

Thanks again. Allan
 
That didn't work -- I get the same error. Thanks for the suggestion

Allan
 

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

Similar Threads


Back
Top