Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-05-07
7
Medium Priority
?
375 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
[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
  • 4
  • 3
7 Comments
 
LVL 16

Assisted Solution

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

Author Comment

by:luchuanc
ID: 24331161
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 2000 total points
ID: 24331191
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:luchuanc
ID: 24336902
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 2000 total points
ID: 24337018
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
ID: 31579232
Thanks a lot cwood-wm-com.
I finally got time to try your idea, super!


Luchuan
0
 
LVL 16

Expert Comment

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

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

604 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