A
Alvin
I have a database I want to distribute and the user places it anywhere on
their pc they want. I need the following script to locat and open that
database "Family.mdb"
How can I do that with the following code? Right now the file path is set
but I would like the Birthdays.exe to locate and open it no matter where it
is saved on the PC.
Thanks in advance.
Alvin
Here is the code I have
*********start*************
Private Sub Form_Load()
' VBS Script to look up upcoming birthday
Const pathMDBFile = "C:\Documents and Settings\Owner\Desktop\Family
Database\Family.mdb"
Const qdfContacts = "Contacts"
' dao constants
Const dbOpenSnapshot = 4
Const dbForwardOnly = 8
Dim dbe, db, ss ' as DBEngine, as Database, as Recordset
Dim displayText ' as string
' create a db engine
Set dbe = CreateObject("DAO.DBEngine.36")
' open the database readonly
Set db = dbe.OpenDatabase(pathMDBFile, False, True)
' get a snapshot of the data
Set ss = db.OpenRecordset(qdfContacts, dbOpenSnapshot, dbForwardOnly)
Shell """C:\Program Files\Microsoft Office\Office10\MSAccess.exe"" " & _
"""C:\Documents and Settings\Owner\Desktop\Family
Database\Family.mdb""", vbMaximizedFocus
' run through any records that may have been returned
Do While Not ss.EOF
' create a simple string, just concatenate the names
' blank lines are ugly
If Len(displayText) > 0 Then displayText = displayText + vbNewLine
displayText = displayText & ss.Fields(0).Value
' next record
ss.MoveNext
Loop
' an empty MsgBox is so unhelpful: use some default text instead!
If Len(displayText) = 0 Then
MsgBox "No birthdays due"
End
End If
' arrange for a neat closedown
ss.Close
db.Close
End
End Sub
Private Sub Label1_Click()
A = MsgBox("This Program was built to help" & Chr(13) & Chr(10) & Chr(10) &
" you keep up with your Birthday list", vbInformation, "Birthday")
End Sub
*********end*************
their pc they want. I need the following script to locat and open that
database "Family.mdb"
How can I do that with the following code? Right now the file path is set
but I would like the Birthdays.exe to locate and open it no matter where it
is saved on the PC.
Thanks in advance.
Alvin
Here is the code I have
*********start*************
Private Sub Form_Load()
' VBS Script to look up upcoming birthday
Const pathMDBFile = "C:\Documents and Settings\Owner\Desktop\Family
Database\Family.mdb"
Const qdfContacts = "Contacts"
' dao constants
Const dbOpenSnapshot = 4
Const dbForwardOnly = 8
Dim dbe, db, ss ' as DBEngine, as Database, as Recordset
Dim displayText ' as string
' create a db engine
Set dbe = CreateObject("DAO.DBEngine.36")
' open the database readonly
Set db = dbe.OpenDatabase(pathMDBFile, False, True)
' get a snapshot of the data
Set ss = db.OpenRecordset(qdfContacts, dbOpenSnapshot, dbForwardOnly)
Shell """C:\Program Files\Microsoft Office\Office10\MSAccess.exe"" " & _
"""C:\Documents and Settings\Owner\Desktop\Family
Database\Family.mdb""", vbMaximizedFocus
' run through any records that may have been returned
Do While Not ss.EOF
' create a simple string, just concatenate the names
' blank lines are ugly
If Len(displayText) > 0 Then displayText = displayText + vbNewLine
displayText = displayText & ss.Fields(0).Value
' next record
ss.MoveNext
Loop
' an empty MsgBox is so unhelpful: use some default text instead!
If Len(displayText) = 0 Then
MsgBox "No birthdays due"
End
End If
' arrange for a neat closedown
ss.Close
db.Close
End
End Sub
Private Sub Label1_Click()
A = MsgBox("This Program was built to help" & Chr(13) & Chr(10) & Chr(10) &
" you keep up with your Birthday list", vbInformation, "Birthday")
End Sub
*********end*************