date field

eggwater

life as a rehearsal
Local time
Today, 22:23
Joined
Aug 14, 2003
Messages
69
I need a date field in a table that first automatically shows the record creation date - i think i have this sussed - default value = now() etc... however I need this to update when a certain criteria is met in another field - e.g. If field = 0 then creation date field stays the same, if field = 1 or 2 then creation date field is updated to what ever date the other field has been changed -

does this make sense?

I have a much more complex question after i get the ansqwer to this
 
You need some code that gets triggered when the "other" field in question has a value of 1 or 2. You should probably use the Form's before update event. That event will "fire" when a change to a record has been made and just before that change gets saved to the database. The code would be something like:

If Me.checkfield=1 or Me.checkfield=2 Then
  Me.RecordCreateDate=Me.Yourotherdatefiled
End If

Of course, substitute the names of your controls for the sample ones I used. Also, the Now() function also provides the time in addition to the date. Use the Date() function if you only need to record the date.

Also note that using the before update event depends on the record actually being changed. If the value of the checkfield you are using is calculated, the event may not fire. If that might be the case, let us know.
 
i'm having trouble getting this to work

I'm new to VB coding - i've successfully implemented some code before but this is proving a problem
 
why isn't this working?

i've tried load of variations on this now but i can't seem to get my date field to update based on the value in the other field - i can do it with a check box but a checkbox is not what i need to use
 
If field1 is your "check field" then put this in the After update event
Code:
If Me.field1=1 Then 
  Me.RecordCreateDate=now()
End If

if you have multiple check fields then in their after update event have them call your first afterupdate event:


Regards
 

Users who are viewing this thread

Back
Top Bottom