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

A Question on Database connectivity

Status
Not open for further replies.

BigCatMCS

Programmer
Apr 29, 2004
57
US

I'm building a database app w/ bound controls (no ado data control) and I can't connect to an Access database. I get the error of "Expected function or variable". I triple checked my work but I spelled all of my variables the same. When I do get the error, it highlights the open method of my connection object. The following is the code:

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


Anyone see anything wrong w/ this code? Thx.
 
Correct Code
==========

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


Thanks
maii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top