Link to home
Start Free TrialLog in
Avatar of printmedia
printmedia

asked on

Create module in access 2003 to open query in another database

Hi all.

We use a switchboard in Access 2003.

I want to be able to open a query that is in another database, the query accepts two date parameters. I created the code provided below, but when I click the switchboard button it gives me the following error: "There was an error executing the command."

Yet if I run it directly from the VBA window it runs fine.

What am I doing wrong?
Thank you in advance!
Function ExpectedShipDateQuery() As String
 
Dim objAccess As Object
Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase "\\myServer\access data\myOtherDatabase.mdb"
objAccess.Visible = True
objAccess.DoCmd.OpenQuery "Expected Ship Date"
Set objAccess = Nothing
 
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of joeyw
joeyw

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of printmedia
printmedia

ASKER

That was it!

Thanks for your help!