I think I found something close to user - proof Method :D
To make myself clear.
I created a notepad file, i created a shortcut for it.
i changed the location of the notepad file, the shortcut is still valid
can i link my DB connection to a .lnk ?
Well today i was working on something really different.. i forgot about this
then i donno why it came into my code
you have to create a shortcut in ur app.path folder to your database file
then u will be free to move ur database anywhere , the shortcut will always point to the correct database path
then u read the database from the shortcut.
this code does the reading :D from shortcut to location
‘Add reference to Microsoft Shell Controls and Automation and add a button to a form.
Dim shl as Shell, file as FolderItem, fld as Folder
Dim lnk as ShellLinkObject, i as Long, folderPath as string
set shl = new Shell
'you can use an input box to get the folder path or app.path as said above
folderPath = app.path & "\"
set fld = shl.NameSpace(folderPath)
'to use browser remove the comment from the next line
' set fld = shl.BrowseForFolder(me.hWnd, "Select Folder that has shortcut file", 0, ssfDESKTOP)
' to use a fixed shortcut name remove the next line
' ShortcutName = "Mydb.lnk"
ShortcutName = InputBox("Enter shortcut name with extention .lnk", "Shortcut name")
If Not Right(ShortcutName, 4) = ".lnk" then
ShortcutName = ShortcutName & ".lnk"
End If
on error resume next
set file = fld.Items.Item(ShortcutName)
If Err <> 0 then
MsgBox ShortcutName & " is inaccessable!", vbCritical
Err.Clear
GoTo exit_sub
else
If file.IsLink then
set lnk = file.GetLink
' redirect.. do the work u want. set the con properties
MsgBox "Name: " & file.Name & vbCrLf & _
"Description: " & lnk.Description & vbCrLf & _
"Path: " & lnk.Path & vbCrLf & _
"WorkingDirectory: " & lnk.WorkingDirectory & vbCrLf, vbInformation
else
MsgBox ShortcutName & " is not a shortcut!", vbInformation
End If
End If
exit_sub:
set lnk = nothing
set file = nothing
set fld = nothing
set shl = nothing
End Sub
that will be for free .. no 20$ required :P
il code baddo tizbit..bass ano.. that is how it can be done