Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving the name of the DB in VBA

Status
Not open for further replies.

chippyles

Technical User
Nov 10, 2004
49
0
0
US
This SQL command in VBA computes the user name, host name, time stamp and the task as the Form or Report name.

Answer this riddle...

Form or Report is to Me.Name as
Name of DB is to ???

I need to capture the name of the Db the person is using so I can differentiate the forms and reports.


DoCmd.SetWarnings False
DoCmd.RunSQL " INSERT INTO LOG_REPORT ( [DATE], [USER], HOST ,TASK )" & _
"SELECT now() AS [DATE], environ('username') AS [USER], environ('computername') AS HOST ,'" & Me.Name & "'"
DoCmd.SetWarnings True
 
Hi,

How about CurrentDB.Name?

Skip,
[sub]
[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue][/sub]
 
Versions 2000+

[tt]currentproject.name[/tt]

Roy-Vidar
 
You can get to the database file name, and the name which you set in Application Title via the Tools ... Startup menu option.

CurrentProject.Name - returns the .mdb file name. Example:

MyDatabase.mdb

CurrentProject.Path - returns the path to the.mdb file. Example:

C:\Databases

CurrentProject.FullName - returns the path and file name. Example:

C:\Databases\MyDatabase.mdb

CurrentDb.Properties("AppTitle") - the name set in Tools ... Startup. Example:

My Example Database Version 1.0


I hope that this is useful.



Bob Stubbs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top