Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-03-2012, 08:23 AM
marooned's Avatar
marooned marooned is offline get access database path in Word vba Windows 7 32bit get access database path in Word vba Office 2007
Novice
get access database path in Word vba
 
Join Date: Jul 2012
Location: Caribbean
Posts: 2
marooned is on a distinguished road
Default get access database path in Word vba

Hi all
I am trying access database to fill a word document. It works fine as I have it now.
I am accessing Access data base as below:



Code:
Dim dbDatabase As Database
Dim rsMedico As Recordset
Dim i As Integer
Dim aResults()
 
Set dbDatabase = OpenDatabase("C:\Users\Rama\Documents\Medprog\Medico.mdb")
 
Set rsMedico = dbDatabase.OpenRecordset("Patients", dbOpenSnapshot)
Instead of hard coding as above I like to get db path by code or connect string. I have tried all like getdbpath, getdbfullpath. I get errors like type mismatch,object variable not set etc.

I need a relative path or soft coding so that I can use this any other computer with access database.
Hope somebody can help

Marooned

Last edited by macropod; 07-04-2012 at 01:55 AM. Reason: Added code tags
Reply With Quote
  #2  
Old 07-04-2012, 02:00 AM
macropod's Avatar
macropod macropod is offline get access database path in Word vba Windows 7 64bit get access database path in Word vba Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Marooned,

If I understand it, correctly, you want to have a dynamic version of:
C:\Users\Rama\Documents\Medprog\
If your document is in the same folder as the database (ie Medprog), you should be able to use:
Set dbDatabase = OpenDatabase(ActiveDocument.Path & "\Medico.mdb")
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-04-2012, 06:37 AM
marooned's Avatar
marooned marooned is offline get access database path in Word vba Windows 7 32bit get access database path in Word vba Office 2007
Novice
get access database path in Word vba
 
Join Date: Jul 2012
Location: Caribbean
Posts: 2
marooned is on a distinguished road
Thumbs up

Hi Paul
Brilliant. Works tremendously. Thanks ever so much.
Marooned
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
get access database path in Word vba How to link a combobox to an access database? Joe Patrick Word 1 10-21-2011 09:01 AM
Exporting many Word files to a database or Excel Mdalu Word 0 05-23-2011 02:55 AM
Excel to lookup Access Database PeterP Excel 1 06-11-2009 12:33 PM
get access database path in Word vba Access database engine with Streets and Trips 2009 dreemsnake Misc 3 05-26-2009 10:25 AM
Populate cells in Word from a database hotlilshan Word 3 12-09-2008 01:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft