Solved

Create module in access 2003 to open query in another database

Posted on 2009-05-13
2
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

733 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