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

Linking Access 97 to a recordset??

Status
Not open for further replies.

luvlylittlelady

Programmer
Joined
Jan 3, 2002
Messages
5
Location
GB
I have written some code to link VB to an access table, evcery time it runs i get an error "91" saying - Object variable or with block variable not set?

Not sure where i am going wrong

Code below is on a button - it keeps pointing to the first line of - Data1.Recordset.Movefirst

**Code**

List1.Clear
List2.Clear

Data1.Recordset.MoveFirst
Text2.Text = UCase(Data1.Recordset.Fields("Hotel ID").Value)
Data2.Recordset.MoveFirst

While Not Data1.Recordset.EOF
List1.AddItem UCase(Data1.Recordset.Fields("Hotel ID").Value)

If UCase(Text1.Text) = UCase(Data1.Recordset.Fields("hotel ID").Value) Then
Text2.Text = UCase(Data1.Recordset.Fields("hotel type").Value)
End If
Data1.Recordset.MoveNext
Wend

Data1.Recordset.MoveFirst

While Not Data2.Recordset.EOF
List2.AddItem UCase(Data2.Recordset.Fields("hotel name").Value)

If UCase(Text1.Text) = UCase(Data2.Recordset.Fields("hotel id").Value) Then
Text3.Text = UCase(Data2.Recordset.Fields("town").Value)
End If
Data2.Recordset.MoveNext
Wend

Data1.Recordset.MoveFirst
Data2.Recordset.MoveFirst
 
VB gives this error because your recordset is'n declared. It might be declared, but VB is sometimes a difficult men, just declare it again before you work with the recordset.
 
Not sure what you mean there? could you explain some more please
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top