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!

Database name in VB 1

Status
Not open for further replies.

AccessAce

Programmer
Dec 11, 2002
105
US
Is there a way to get the userdefined database name, the name given in the Tool/Startup dialog box, assigned to a variable?

I am creating a tool to mange multiple databases. I am placing code in each database to update a table in this mangement tool. I am currently hardcoding the database names but would like to change that as I am managing both development and production versions of the databases.

Any ideas?
 
If the 'AppTitle' property is not set then the property doesn't exist, and trying to access it generates error 3270. A simple function can check for it and return either the AppTitle or the name of the database file:

Code:
Public Function GetAppName(ByRef db As Database) As String
On Error GoTo ErrHandler
  
  ' Attempt to get Title:
  GetAppName = db.Properties("AppTitle")
  
ExitHere:
  Exit Function
ErrHandler:
  If Err = 3270 Then    ' Property not Found
    ' If no Title found, use the database name:
    GetAppName = Mid(db.Name, InStrRev(db.Name, "\") + 1)
  End If
  Resume ExitHere
End Function
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Bingo. That's exactly what I was looking for. Thank you much VBslammer.

You get a star!
 
dang it, I knew the answer to your question AccessAce, vbSlammer is quick, hopefully, I have other chances to return the favor. MMFL-
Mavericks Fan For Life
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top