Opening a database with app.path

05-29-2002, 11:58 AM
I have tried to open a database with app.path and am getting an error. It looks like it is just looking within the VB folder. Is there something I should know? Here is code:

Dim db As Database
Dim rs As Recordset

Private Sub cmdRun_Click()
Set db = OpenDatabase_ &(App.Path& "\techheadsdatabase_2.mdb")
Set rs = db.OpenRecordset(Customers)
For i = 1 To rs.RecordCount
picBox.Print db(LastName)
Next i
End Sub

05-29-2002, 12:19 PM
Try this...

Set db = OpenDatabase(App.Path & "\techheadsdatabase_2.mdb")

Keep in mind that App.path is the location of your current project.

AND if that path is in the root drive ( c:) there is already a backslash. (ie "c:\")

05-29-2002, 12:56 PM
app.path will return the path to VB if you haven't saved your project yet.

05-29-2002, 12:58 PM
Good point ScotK

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum