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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Database Name 3

Status
Not open for further replies.

cneill

Instructor
Mar 18, 2003
210
GB
Hi,

I am currently using
Dir([CurrentDb].[Name],16) in Access 2002, but will shortly be moving to 2007, I have noticed that this code does not work in 2007 does anyone know what I should be using for 2007?

Thanks

cneill
 
Have just tried this in 2007 and it works fine. In what context are you using this that it doesn't work?

John
 
This works in my version of Access 2007.
 
Hi Majp/jrbarnett

it is just a simple text field on the login screen, the first time, I tried my database in 2007 it just showed Name? in the text box as if it did not know what it was looking for, I will convert another copy and have another look at it, unless you have any other thoughts?

thanks

cneill
 
ensure you have updated all windows and office service packs.
 
Once you have updated all service packs, uncheck the reference to VBA then recheck the reference. This could be a symptom of a bigger problem with the vba reference. Out of curiousity, try some of these string functions in the immediate window to see if there are any other problems: left, instr, len, right, mid.
 
For information, you can make your code slightly more self documenting by using:

Dir([CurrentDb].[Name], vbDirectory)

instead.

John
 
Seems you're using a ControlSource and thus get the #Name ?.
In a standard code module create the following function:
Code:
Public Function getDBname()
getDBname = Dir(CurrentDb.Name, vbDirectory)
End Function
and then use this ControlSource property:
Code:
=getDBname()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top