1

all I need to run a function that will run multiple reports in different access databases... ad DB to rule them all :) here the structure: in my multi_report.accdb I have a form with a button that is running this code:

Private Sub Comando1_Click()

Dim db_report As String
Dim objAccess As Object
Dim ctr As Date

'TICKETS
db_report = "\\sdocenco01\OPC\11_SCL\TICKETS\ticket.accdb"
Set objAccess = GetObject(db_report) 'opens other db
objAccess.Visible = True
objAccess.Run "report_tickets" 'runs function in other db
objAccess.Quit 'quits other db
Set objAccess = Nothing

'PROCESSI
db_report = "\\sdocenco01\OPC\11_SCL\PROCESSI\utilita.accdb"
Set objAccess = GetObject(db_report)
objAccess.Visible = True
objAccess.Run "report_processi"
objAccess.Quit
Set objAccess = Nothing

...

in the line

objAccess.Run "report_tickets" 

i get a run-time error '2517' routine report_tickets not found

I tried different codes like

objAccess.Run "ticket.report_tickets" 

or

objAccess.Run "ticket.Database1.report_tickets" 

but nothing seems to work

in the \sdocenco01\OPC\11_SCL\TICKETS\ticket.accdb i have this code:

Public Function report_tickets()
DoCmd.SetWarnings False
Dim cdb As DAO.Database, qdf As DAO.QueryDef
Set cdb = CurrentDb
...
End Function

1 Answer 1

1

First, according to the Docs, the project name must be included:

The name of the Function or Sub procedure to be run. If you are calling a procedure in another database, use the project name and the procedure name separated by a dot in the form: "projectname.procedurename"

Next, I guess the "Report_" prefix confuses. Try renaming the functions and call them like:

objAccess.Run "YourProjectName.ReportTickets" 
Sign up to request clarification or add additional context in comments.

7 Comments

See expanded answer, please.
nope, i tried... still not working... same error
Then double-check everything. It is tested and runs nicely here
i actually did naming the function as you suggeste ReportTickets... i really do not know what to do
Try rebuilding just this from scratch as simple as possible. My ReportTickets only popped a MsgBox.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.