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

Error 91, need help debugging this

Status
Not open for further replies.
Jan 5, 2004
34
US
I am attempting to populate the table [numbers] with this output. I keep getting Error 91, "Object variable, or with block variable not set" Unable to figure this out.

Pls help
Click


CODE>


Private Sub Command0_Click()

Dim ThisDB As DAO.Database
Dim v As Integer
Dim w As Integer
Dim x As Integer

Dim numbers As DAO.Recordset
Dim rstnumbers As DAO.Recordset

Dim rstnum As DAO.Recordset


For v = 1 To 20
For w = 30 To 60
For x = 70 To 100


Set rstnumbers = ThisDB.OpenRecordset("numbers")

With rstnum
.AddNew
.Fields("1") = v
.Fields("2") = w
.Fields("3") = x
.Update
.Close
End With


Next
Next
Next



End Sub

Email Service Free from Banner ads.
 
See modified code below

Private Sub Command0_Click()

Dim ThisDB As DAO.Database
Dim v As Integer
Dim w As Integer
Dim x As Integer

Dim numbers As DAO.Recordset
Dim rstnumbers As DAO.Recordset

Dim rstnum As DAO.Recordset

SET ThisDb as CurrentDB() ' <****
For v = 1 To 20
For w = 30 To 60
For x = 70 To 100


Set rstnumbers = ThisDB.OpenRecordset("numbers")

With rstnum
.AddNew
.Fields("1") = v
.Fields("2") = w
.Fields("3") = x
.Update
.Close
End With


Next
Next
Next

SET ThisDB = Nothing ' <*****

End Sub

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top