Solved

Create module in access 2003 to open query in another database

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

770 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