Help with a batch file please

T

Tony Williams

I have created a batch file following the instructions from a post by Albert
Kallal to run a routine that prints a report. here is my script:

dim accessApp
set accessApp = createObject("Access.Application")
accessApp.OpenCurrentDataBase("C:\Documents and Settings\Owner\My
Documents\TimeandBilling.mdb")

accessApp.Run "macinvoice"
accessApp.Quit
set accessApp = nothing

The module in the mdb file is called macinvoice and this is the code:
Option Compare Database

'------------------------------------------------------------
' macinvoice
'
'------------------------------------------------------------
Function macinvoice()
On Error GoTo macinvoice_Err

DoCmd.OpenReport "Invoice List", acViewPreview, "", "", acNormal


macinvoice_Exit:
Exit Function

macinvoice_Err:
MsgBox Error$
Resume macinvoice_Exit

End Function


However when I click on the script icon Access opens at the right database
but I get an error message that says it can't find the procedure 'macinvoice'
even though the module is listed as macinvoice.

I must admit to being a little out of my depth here so can anyone help?
Thanks
Tony
 
S

Stuart McCall

Tony Williams said:
I have created a batch file following the instructions from a post by
Albert
Kallal to run a routine that prints a report. here is my script:

dim accessApp
set accessApp = createObject("Access.Application")
accessApp.OpenCurrentDataBase("C:\Documents and Settings\Owner\My
Documents\TimeandBilling.mdb")

accessApp.Run "macinvoice"
accessApp.Quit
set accessApp = nothing

The module in the mdb file is called macinvoice and this is the code:
Option Compare Database

'------------------------------------------------------------
' macinvoice
'
'------------------------------------------------------------
Function macinvoice()
On Error GoTo macinvoice_Err

DoCmd.OpenReport "Invoice List", acViewPreview, "", "", acNormal


macinvoice_Exit:
Exit Function

macinvoice_Err:
MsgBox Error$
Resume macinvoice_Exit

End Function


However when I click on the script icon Access opens at the right database
but I get an error message that says it can't find the procedure
'macinvoice'
even though the module is listed as macinvoice.

I must admit to being a little out of my depth here so can anyone help?
Thanks
Tony

There's nothing wrong with your batch file. The problem is that you've named
the module with the same name as the procedure. Access doesn't like this at
all. Rename the module to say modmacinvoice. Renaming the module will not
affect anything else in your app.
 

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