Solved

Create module in access 2003 to open query in another database

Posted on 2009-05-13
2
325 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

757 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

24 Experts available now in Live!

Get 1:1 Help Now