Object Required Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I keep getting an "Object Required" error. I have very little experience in
VBA and could use some help.

Private Sub PrintButton_Click()
On Error GoTo Err_PrintButton_Click

Dim stDocName As String
Dim curGC As Long

curGC = DMax("[GCNum]", "GCItemsTemp") + 1
Do Until GCItemsTemp.EOF = True
With GCItemsTemp
If PRNT.Value = yes Then
.Edit
GCNum.Value = curGC
curGC = curGC + 1
.Update
End If
.MoveNext
End With

Loop


stDocName = "GCPrinter"
DoCmd.OpenReport stDocName, acNormal

Exit_PrintButton_Click:
Exit Sub

Err_PrintButton_Click:
MsgBox Err.Description
Resume Exit_PrintButton_Click

End Sub


Thanks in advance for any help!
 
Do Until GCItemsTemp.EOF = True

the variable GCItemsTemp is not declare and
set.


what is it that you really want to accomplished?
can u please explain in further.
 
GCItemsTemp is a table with a list of records.
I am trying to locate the records that were selected in the form by checking
the PRNT control. Then, I am assigning the next available number to GCNum.
Finally, I am printing a report on those records that were selected.

I will try your suggestion. Thanks
 
I got rid of the Object Required error... now how do I get it to actually
edit the record?

Dim stDocName As String
Dim curGC As Long

curGC = DMax("[GCNum]", "GCItemsTemp") + 1
Set db = CurrentDb
Set rs = db.OpenRecordset("GCItemsTemp")

Do Until rs.EOF = True
If PRNT.Value = yes Then
rs.Edit
rs.GCNum = curGC
curGC = curGC + 1
rs.Update
End If
rs.MoveNext

Loop
rs.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top