Solved

MS Access 2007 Remote Query - Can we pass in the folder path?

Posted on 2009-05-07
7
300 Views
Last Modified: 2013-11-29
Hi,

I have several remote queries based on another Access database on another folder.
Is there a way to pass the path  to a remote Query instead of hard code the path?

Thanks,
Luchuan
0
Comment
Question by:luchuanc
  • 4
  • 3
7 Comments
 
LVL 16

Assisted Solution

by:Chuck Wood
Chuck Wood earned 500 total points
Comment Utility
Do you mean you are querying a linked table (in another database) using a query in your database?
0
 

Author Comment

by:luchuanc
Comment Utility
Hi cwood-wm-com:

Yes, I have the following sql

select ..... from tblPtVisit in "I:\test\testdb.accdb"

and I:\test\testdb.accdb is another MS Access Database.

Thanks,

Luchuan
0
 
LVL 16

Assisted Solution

by:Chuck Wood
Chuck Wood earned 500 total points
Comment Utility
I think this is what you need:
Private Function CreateSQL(ByRef strSQL As String, ByVal strDbPath As String)

  strSQL = "SELECT * FROM tblPtVisit IN " & strDbPath

End Function

Open in new window

0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:luchuanc
Comment Utility
Hi cwood-wm-com:

Good idea, is there a way to have the query call this function?
(It seems the Query tool does not recognize the VBA function, is this true)

Thanks,

Luchuan
0
 
LVL 16

Accepted Solution

by:
Chuck Wood earned 500 total points
Comment Utility
Luchuan,
Put the snippet function in a code module (other than a form module) and then put this in a field in your query:

Database: DbPath()
Public Function DbPath()

  DbPath = "I:\test\testdb.accdb"

  ' OR

  'DbPath = Forms!frmMyForm.txtDebPath

End Function

Open in new window

0
 

Author Closing Comment

by:luchuanc
Comment Utility
Thanks a lot cwood-wm-com.
I finally got time to try your idea, super!


Luchuan
0
 
LVL 16

Expert Comment

by:Chuck Wood
Comment Utility
You are welcome. I am glad it worked for you. Good luck on your project.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
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.

744 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

13 Experts available now in Live!

Get 1:1 Help Now