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!
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help!