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

declaring a recordset 1

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
Can someone help me declare a recordset? I am in the habit of using Me.Recordsource ="SELECT * FROM MyTable" and then Me.Recordset.MoveNext, etc. however... I am trying to make a global function and apparently the Me. anything isn't working out. This is what I have so far:

Dim MyRecSet as Recordset
MyRecSet.Source = "SELECT * FROM MyTable"
MyRecSet.MoveFirst
txtTitle = MyRecSet.Fields("Title")

I am getting run-time error 91: "Object variable or With block variable not set" when I go to set the source of the recordset. What am I missing? Thanks!
 
Hope this helps...

Dim MyRecSet As Recordset
Dim db As Database

Set db = CurrentDb
Set MyRecSet = db.OpenRecordset("SELECT * FROM MyTable")
MyRecSet.MoveFirst
txtTitle = MyRecSet.Fields("Title")

Lixie
 
I'm getting the following error: User-defined type not defined. Any idea what's going wrong? Thanks!
 
Nevermind.. I didn't check the Microsoft DAO 3.51 object library in VB. Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top