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

A Problem w/ Database Connection

Status
Not open for further replies.

BigCatMCS

Programmer
Apr 29, 2004
57
US

I've been having trouble connecting to an Access database without using the ADO data control. Whenever I run the program, VB highlights the open method of the connection and gives me an error msg of "Expected function or variable". I checked and made sure my variables were spelled the same throughout the module, but this hasn't helped. There is part of the code below. Can anyone see a problem w/ it? Thx.


Option Explicit
Dim mcnAP As Connection
Dim mrsVendors As Recordset

______________________________________


Private Sub Form_Load()
Set mcnAP = New Connection
Set mrsVendors = New Recordset

mcnAP.CursorLocation = adUseClient

mcnAP.Open = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Data Source=A:\Chapter6Bound\AccountsPayable.mdb"

mrsVendors.Open "Select * From Vendors Order By _ VendorName", _
mcnAP, adOpenStatic, adLockOptimistic, adCmdText

LoadControls
SetNavigationButtons True

End Sub
 
Well you dont need the equal sign because .Open() is a method of the connection object.

It might help to think about it this way:
Call mcnAP.Open("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=A:\Chapter6Bound\AccountsPayable.mdb" )

 

Thanks a lot. I didn't even see that stupid = sign.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top