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

run tim error 3021

Status
Not open for further replies.

autoIT

IS-IT--Management
May 10, 2006
68
US
ok pretty simple question:

I am attempting to write date to a table. There is nothing in the table yet, therefore I get a run-time error'3021'. I am trying diligently to get write an error handler to get get that one first record in but to no prevail. This is a table that stores queries info so it is always cleared before new info comes in.

What do I do?


Adam
 
this also include my attemp at the error handler



Private Sub btnQualify_Click()
Dim Ctr As Integer
Dim TempVin As String
Dim VinKeyAnswer As String

CurrentDb.Execute "delete from BidCounter"
On Error GoTo error_handler

Vehicles.MoveFirst

Do Until Vehicles.EOF
TempVin = Vehicles.Fields.Item("Vin Key")
Bids.MoveFirst
Do Until Bids.EOF
Ctr = 0
If Bids.Fields.Item("Vin Key") = TempVin Then
Ctr = Ctr + 1
Bids.MoveNext
Else
Bids.MoveNext
End If

If Ctr >= 3 Then
BidCounter.AddNew
BidCounter.Fields.Item("Vin Key") = TempVin
BidCounter.Fields.Item("Bids") = Ctr
Vehicles.MoveNext
Else
Vehicles.MoveNext
End If
Loop




Loop
MsgBox ("The QUALIFYING BID REPORT is now ready to be sent to Excel")
btnQualBidRpt.Visible = True
btnQualBidRpt.SetFocus
btnQualify.Visible = False
btnEnterBid.Visible = False
btnGetWin.Visible = False


Exit Sub
error_handler:
If Err.Description = "Run-time errror '3021':" Then
BidCounter.Fields.Item("Vin Key") = TempVin
BidCounter.Fields.Item("Bids") = Ctr
End If

End Sub
 
I think you missed the .Update

Code:
If Ctr >= 3 Then
   BidCounter.AddNew
      BidCounter.Fields.Item("Vin Key") = TempVin
      BidCounter.Fields.Item("Bids") = Ctr
   BidCounter.Update
   Vehicles.MoveNext
Else
   Vehicles.MoveNext
End If
 
will that get rid of my error, and if so how?
 
problem is i do not want to record every instance, just want to count every instance and put the total instances on one line with the vin #
 
ok i know im all over the place here, i see what the update function will do, problem is when it comes into this part of the code bidcounter.addnew, it attempts to make a new line on an already empty table, how do i avoid this making sure every time thereafter it creates a new line
 
Yes! the .addnew will add a new record what are you trying to do? Do you want to edit a record that already exists then you use the .edit.

Second of all, it seems to me that your ctr (counter) will never reach 3 because you reset it through each loop to 0.

Please clarify.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top