Run-Time Error '2424'

S

Secret Squirrel

I'm getting a run-time error '2424', The expression you entered has a field,
control, or property name that Test Database can't find.

I get this error when I try to delete a record via my form. I debug the
error and it goes to some VB code that I have on a combo box. The combo box
has two values to choose from "Yes" & "No". This is what the code is on my
combo box:

If Me.ShippingName = "Yes" Then
Me.ShipToName = Me.Customer
Else

End If

Anyone have any idea why I'm getting this error when I try to delete a
record? All the control names and record source names are spelled correctly.
I've tried compacting and repairing the db as well as verifying that all the
references are being used. But still can't get it to work. When I shut that
code off then it works fine. Any ideas?
 
O

Ofer Cohen

I'm not sure that the case, I got this error message even when it was spelled
correctly in two occasions
1. The field name has a key word name in Access, but it seem not to be the
case
2. There were two text fields in the form: one with a name such as Customer
and the other field was bounded to the field Customer but with a different
name.
If that the case, change he field name that has Customer to Customer1
 
S

Secret Squirrel

I tried that but it's still doing the same thing. It will allow me to delete
the record if that code is not there. Why is it that I only get this error
with that code?
 
O

Ofer Cohen

When do you run this code, mybe it's running it when there is no record.
Try this
If Me.RecordsetClone.RecordCount > 0 Then
If Me.ShippingName = "Yes" Then
Me.ShipToName = Me.Customer
end if
en if
 
S

Secret Squirrel

That didn't work either. Now after I added that code I get this error:

Run-time error '7951'
You entered an expression that has an invalid reference to the
RecordSetClone property.
 
S

Secret Squirrel

I was just doing some testing and if I create 2 records and then go back and
delete the first one it works fine but if I try to delete the last record I
get the error messages. What do you think now?
 
O

Ofer Cohen

That what I tried to check with the RecordCount, On which event do you have
this code?
 
S

Secret Squirrel

I have this on the AfterUpdate event of the combo box and the current event
of the form.
 
O

Ofer Cohen

I can't see why the After Update event of the combo should run after deleting
the record, I tried it and either the after update or the On Current event
were fired after deleting.
Check the OnDelete Property of the form, do you have anythig there that
calls this event.
 
S

Secret Squirrel

I don't have any code in the OnDelete event of the form. I do have some code
in the AfterDelConfirm event. This code is used to reset the AutoNumber
sequence if the the last record is deleted. It allows the system to reset the
AutoNumber back to the next sequential number. Could this be causing the
problem? Here is the code:

On Error GoTo ErrTrap
Dim Rsc As String

Rsc = Me.RecordSource
' Take action only if the deleted records are contiguous to the New Record
If Me.NewRecord = True Then
DoCmd.Echo False
Me.RecordSource = ""
P_SetAutoNum "tblGrindAllCerts", "CertID"
Me.RecordSource = Rsc
DoCmd.Echo True
Me.Repaint
DoCmd.GoToRecord , , acNewRec
End If ' Me.NewRecord = True

ExitPoint:
On Error GoTo 0
Exit Sub

ErrTrap:
MsgBox Err.Number & " - " & Err.Description
Resume ExitPoint

And then I have this code that the above points to:

On Error GoTo ErrTrap
Dim Qst As String, NumStart As Long

' Set Next AutNumber as one more than the max of
' those now existing
NumStart = Nz(DMax(Pkn, Tnm), 0) + 1
Qst = "ALTER TABLE " & Tnm & " ALTER COLUMN " & _
Pkn & " COUNTER (" & NumStart & ", 1);"
CurrentDb.Execute Qst, dbFailOnError

ExitPoint:
On Error GoTo 0
Exit Sub

ErrTrap:
MsgBox Err.Number & " - " & Err.Description
Resume ExitPoint
 

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

Top