Binding Access Form/controls to ADO recordset

D

DJJ

I have created a form with a textbox which I want to bind to ADO recordset
consisting of data pulled from a MySQL database. I have tried setting the
recordset property of the form and the record source property of the textbox
in code but all I get are data mismatches and other errors. Here is my
connection code:



Option Compare Database
Dim Conn As ADODB.Connection
Dim rsInventory As ADODB.Recordset
Dim strConn As String


Private Sub Form_Open(Cancel As Integer)



strConn = "Provider=MSDASQL.1;Persist Security Info=False;Data
Source=BusinessMind"



Set Conn = New ADODB.Connection
Conn.Open strConn

Set rsInventory = New ADODB.Recordset
rsInventory.Open "SELECT stock_id FROM inventory WHERE stock_id = '1.1 MM
BR'", Conn, adOpenStatic, adLockOptimistic


End Sub


Private Sub Form_Close()



rsInventory.Close
Conn.Close
Set rsInventory = Nothing
Set Conn = Nothing



End Sub



Thanx



DJJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top