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

SET database to an Access db in VB

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
Hi all - I want to display information about an Access 2000 database. But when I define the path explicitly in the Set statement, I get a Type Mismatch error.

I copied most of this code from an Access example....
so in VB 6, I am unable to reference (or point) to the database I need info on.

Thanks for your tips! John


Function GetSummaryInfo(strPropName As String) As String
Dim dbs As Database, cnt As Container
Dim doc As Document, prp As Property

Const conPropertyNotFound = 3270
On Error GoTo GetSummary_Err


Set dbs = "D:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb" '... get Type mismatch error

Set cnt = dbs.Containers!Databases
Set doc = cnt.Documents!SummaryInfo
doc.Properties.Refresh
GetSummaryInfo = doc.Properties(strPropName)
 
try this,

Set dbs = OpenDatabase("D:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb")

or

put the database in the same folder as vb program that you are working on and use the App.Path

Set dbs = OpenDatabase(App.Path & "\Pack.mdb")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top