[RESOLVED] database Access using Vb
I am trying to get data from MS access table using the code below. I am using VB6.3 and I have created ODBC as my_cn point to database file (.mbd). When I run this code, I get a runtime error 3001 "Argumant are of wrong type, are out of acceptable range or are in conflict with one another".
When I click debug it highlights "rs.open..." code line.
Please let me kow what missing.
Thanks
Question_1
CODE:
Private Sub form_load()
Dim rs As ADODB.Recordset
strSQL = "SELECT * from MasterTable where SWCR = 13;"
Set rs = New ADODB.Recordset
rs.Open strSQL, my_cn, adOpenStatic, adLockReadOnly
retrieveValue = rs(0).Value
MsgBox ("value:" & retrieveValue)
rs.Close
Set rs = Nothing
End Sub
Re: database Access using Vb
VB6.3 would be Access VBA
Moved From FAQ section
Re: database Access using Vb
If you're in Access you don't use ODBC. Are you trying to connect to a Mysql db or similar? What is the code where you set your connection?
Re: database Access using Vb
Yes I am in MSAccess, have created a form bound to a table. I am trying to extract data from the table 'MasterTable' into a local variable in VB which I can use later in my code to apply to some equations.
I am not a hardcore software. I am more into embedded tech so quite new to VB interface to MSaccess database.
Re: database Access using Vb
Never Mind I got it myself. thanks anyways.