Prev: amizade
Next: 2007 Toolbars On Reports
From: Tony Williams on 5 Apr 2010 06:17 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
From: TonyWilliams via AccessMonster.com on 5 Apr 2010 07:34 I have changed the module from a Function to a Public Sub and it still doesn't work. here is the script and code as it satnds now. 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 ' '------------------------------------------------------------ Public Sub macinvoice() On Error GoTo macinvoice_Err DoCmd.OpenReport "Invoice List", acViewPreview, "", "", acNormal macinvoice_Exit: Exit Sub macinvoice_Err: MsgBox Error$ Resume macinvoice_Exit End Sub I must admit to being a little out of my depth here so can anyone help? Thanks Tony Tony Williams wrote: >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 -- Why don't my grey cells communicate with each as fast as they used to? I hate getting old! Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-reports/201004/1
From: John Spencer on 5 Apr 2010 08:37 You should NOT save a module with same name as a procedure. That will lead to an error message when you attempt to use the procedure (function) since the names of modules and VBA procedures use the same "name space". Try changing the name of the module to modMacInvoice and see if that fixes your problem. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County TonyWilliams via AccessMonster.com wrote: > > > Tony Williams wrote: >> 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 >
From: TonyWilliams via AccessMonster.com on 5 Apr 2010 08:57 Thanks John. I changed the name as you suggested but still get a message that says Access can't find the procedure "Modmacinvoice" with error code 800A09D5 Access opens when I run the script but it appeasr not to be able to find the procedure that runs the report. Thanks again Tony John Spencer wrote: >You should NOT save a module with same name as a procedure. That will lead to >an error message when you attempt to use the procedure (function) since the >names of modules and VBA procedures use the same "name space". > >Try changing the name of the module to modMacInvoice and see if that fixes >your problem. > >John Spencer >Access MVP 2002-2005, 2007-2010 >The Hilltop Institute >University of Maryland Baltimore County > >>> 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: >[quoted text clipped - 36 lines] >>> Thanks >>> Tony -- Why don't my grey cells communicate with each as fast as they used to? I hate getting old! Message posted via http://www.accessmonster.com
From: John Spencer on 5 Apr 2010 12:06
Did you change the name in the script? You should not do that. You change the name of the VBA code module. SO in the AccessApp (TimeAndBilling) you would have a module named ModMacInvoice and in that module you would have a FUNCTION named MacInvoice. If that does not fix the problem, then I hope Albert Kallal happens onto this thread. Then the script would use MacInvoice. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County TonyWilliams via AccessMonster.com wrote: > Thanks John. I changed the name as you suggested but still get a message that > says Access can't find the procedure "Modmacinvoice" with error code 800A09D5 > > > Access opens when I run the script but it appeasr not to be able to find the > procedure that runs the report. > > Thanks again > Tony > > John Spencer wrote: >> You should NOT save a module with same name as a procedure. That will lead to >> an error message when you attempt to use the procedure (function) since the >> names of modules and VBA procedures use the same "name space". >> >> Try changing the name of the module to modMacInvoice and see if that fixes >> your problem. >> >> John Spencer >> Access MVP 2002-2005, 2007-2010 >> The Hilltop Institute >> University of Maryland Baltimore County >> >>>> 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: >> [quoted text clipped - 36 lines] >>>> Thanks >>>> Tony > |