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

Total newbie question

Status
Not open for further replies.

dukeslater

Technical User
Jan 16, 2001
87
US
Simple frontend to an Access database; as we perform server maintenance the database will change location.

I've trapped for a changed database location and the user can navigate through the dialog to specify the new location. However, the next time the application is opened the dialog reappears - in other words, the new location is not retained within the application.

How can I get the path to 'stick'?

Thanks!
 
here is how you would set that up. you could also store the path in the registry, but that gets more complicated.

When the form loads:
Code:
Dim PathFile As String  'used to check for text file with path
Dim AccessFile As String 'use to check for .mdb file 
Dim DBFileName As String 'use to store path and file to DB

PathFile = Dir(App.Path & "\DBPath") 
If PathFile = "" Then GoTo ShowDialog 'no saved path
'if you are here, there was a saved path 
Open App.Path & "\DBPath" For Input As #1 
Line Input #1, DBFileName 'load the path you saved last time
Close #1
AccessFile = Dir(DBFileName) 
If AccessFile = "" Then GoTo ShowDialog 'saved path invalid 
'if you are here there was a saved path and it was valid
'you don't need to show the dialog. 
GoTo SkipDialog 
ShowDialog: 
'Show the dialog here to get path from user put the path 
'including filename into DBFileName 
SkipDialog: 

Open App.Path & "\DBPath" For OutPut As #1 
Print #1, DBFileName 'this should include the full path & filename 
Close #1 

'One way or another there is now a valid path to the DB and 
'it is saved to the file.  Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?  
For innovative, low cost solutions check out my website. 
[URL unfurl="true"]www.plccontroltechnologies.com[/URL]
 
Some minor tweaking for my particular situation and it works perfectly - thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top