Any reason why......

pnrjack
05-30-2002, 12:12 PM
Anyreason why after I declare a rs that it would give me the option to use rs.open? .open does not come up as a choice.

reboot
05-30-2002, 12:14 PM
Possibly you don't have a reference to the appropriate object library?

pnrjack
05-30-2002, 12:15 PM
Do you know which one I would need? Using VB 6 with Access 1997.

Anis
05-30-2002, 12:18 PM
may be coz, you havent declare it as

Dim rs as Adodb.Recordset

reboot
05-30-2002, 12:19 PM
Depends on what you're using. ADO, DAO, ? For instance, if ADO, go under your Project->References menu and select the ADO reference.

pnrjack
05-30-2002, 12:20 PM
I believe it is a DAO...is it the same for that? I tried
Dim rs as dao.recordset and the following code but no luck:

strSQL = "SELECT * FROM Products"
rs.Open strSQL, dbs, adOpenForwardOnly, adLockReadOnly
rs.MoveLast
rs.MoveFirst

it is not giving the .open as a choice

reboot
05-30-2002, 12:24 PM
What you just posted is ADO code.

pnrjack
05-30-2002, 12:27 PM
I am a little lost as to the difference. What references need to be added with ADO?

ScotK
05-30-2002, 12:50 PM
"Microsoft ActiveX Data Objects 2.5 Library". Your version may be different, I think 2.7 is the latest but someone will correct me if I'm wrong

Anis
05-30-2002, 12:53 PM
Try Adding Data Envionment.
It will work.

pnrjack
05-30-2002, 12:57 PM
How would I DIM these, right now I have...
Dim Data1 As Database
Dim rs As New ADODB.Recordset

and it is giving me a type mismatch with form load:
Set Data1 = OpenDatabase(App.Path & "\TechHeadsDb1.mdb")
Set rs = Data1.OpenRecordset("Products", dbOpenDynaset)

Thanks for your help

Anis
05-30-2002, 01:04 PM
Here is a Sample code for you..

Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\anis.mdb;" & _
"Uid=admin;" & _
"Pwd=anis;"
Dim sql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
sql = "select * from employee order by name"
rs.Open sql, con

reboot
05-30-2002, 01:12 PM
You're mixing ADO and DAO together.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum