How to get database name and location in VBA

  • Thread starter Thread starter Keith Reilly
  • Start date Start date
K

Keith Reilly

I made a form in VBA that will open microsoft word start a mail merge
and give it a certian table. the only problem is in my code i have to
write in the location and name of the database. what i want is a dynamic
variable so i can check what the name of the database is and where then
give that to microsoft word. right now if the name changes or its moved
this form is broken. here is the code that needs the variable

objWord.MailMerge.OpenDataSource _
Name:="C:\Program Files\School Database\" & _
"RyeNursery.mdb", _
LinkToSource:=True

so i want

objWord.MailMerge.OpenDataSource _
Name:= strPath & _
strDatabaseName, _
LinkToSource:=True

how do i get the path and database name? is this possible? any help is
appreciated
 
Open any Module, View the Immediate Window, type in "? CurrentDB.Name"
without the quote marks and see if that doesn't return what you are looking
for.

Larry
 
I think you need to look at CurrentProject.FullName in the
Help. Although, IIRC, the help implies it's more relevant
to adp's it will also return the fully qualified name for
the current mdb I think.

Also relevant may be CodeProject.

--
Nick Coe (UK)
http://www.alphacos.co.uk/




In Keith Reilly typed:
 
Back
Top