Solved

Create module in access 2003 to open query in another database

Posted on 2009-05-13
2
337 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:printmedia
2 Comments
 
LVL 4

Accepted Solution

by:
joeyw earned 500 total points
ID: 24374463
Since this is a function, access is expecting to return a value in  expectedshipdatequery.  You are not setting that value to anything.  Do you want a value returned from the other database or are you just using the parameters to update something in the other database?
0
 

Author Comment

by:printmedia
ID: 24374486
That was it!

Thanks for your help!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now