Error 2424

deltagracesun

New member
Local time
Today, 16:35
Joined
Mar 27, 2012
Messages
5
I have a pop up form that has the following SIMPLE code just to change the color of two fields based on the date.

If Me.[ExpDate] < Now() + 90 And Me.[ExpDate] > Now() Then
Me.[Training].BackColor = RGB(255, 255, 0)
Me.[ExpDate].BackColor = RGB(255, 255, 0)
ElseIf Me.[ExpDate] < Now() Then
Me.[Training].BackColor = RGB(255, 0, 0)
Me.[ExpDate].BackColor = RGB(255, 0, 0)
Else
Me.[Training].BackColor = vbWhite
Me.[ExpDate].BackColor = vbWhite
End If

This works perfectly... So, I can enter a record with only these two fields and the colors work as designed. The problem is when i go to delete a record, I get this Error 2424 (can't find field, control, or property). The error only occurs when in Form View. If I change the form to Datasheet view, I can delete without any error. The debug point is on the first line of the code. Is someone able to help here as I have spent a while on this doing research and haven't uncovered anything that I can use. Thanks.
 
Hi,

Try using DateDiff() function, insead of '+'
If ExpDate is not a date control, try CDate(ExpDate).
the idea is to use date data types and operators.

Hope I am of some hep
 
First off, where do you have this code?

Second, if it is on the form's Current event, then I would just put an error handler in and bypass it if you get the 2424 as the Err.Number.

Code:
On Error GoTo err_handler
 
'  your code here
 
 
MyExit:
  Exit Sub
 
err_handler:
   If Err.Number <> 2424 Then
      MsgBox Err.Description, vbExclamation, "Error #: " & Err.Number
      Resume MyExit
   End If
      Resume Next
 
OMG... boblarson... you are a GOD. Works perfectly. Thanks much. This was my first post today. Usually I spend hours trying to figure something out. Thanks a bunch!:D
 

Users who are viewing this thread

Back
Top Bottom