Solved

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

Posted on 2009-05-07
7
323 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
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 500 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
Back Up Your Microsoft Windows Server®

Back up 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
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 500 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

777 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