Opening a database with app.path

pnrjack
05-29-2002, 12:58 PM
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)
rs.MoveLast
rs.MoveFirst
For i = 1 To rs.RecordCount
picBox.Print db(LastName)
Next i
End Sub

Robby
05-29-2002, 01: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:\")

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

Robby
05-29-2002, 01:58 PM
Good point ScotK

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum