Field value based on conditional (previous field value)

mg55345

Registered User.
Local time
Today, 00:00
Joined
Sep 24, 2007
Messages
12
Hi everyone,

I am looking for help on how to select a value based on the value of a calculated field.

If you look at the attached screenshot you will see a form. After the user enters DOB (date of birth), Age ([ArrestedAge]) is calculated based on the following control source:

Code:
 =DateDiff("yyyy",[ArrestedDOB],Now())+Int(Format(Now(),"mmdd")<Format([ArrestedDOB],"mmdd"))


The "Status" field is a dropdown with the following options:
Under 18
18 or Older
Unknown

I want this field to autoselect "18 or Older" or "Under 18" depending on the age calculated in ArrestedAge field.

Thank you all in advance for your help with this.
 

Attachments

  • status.gif
    status.gif
    12.1 KB · Views: 123
You could do something like the following in the after update event of the DOB field

Code:
If DateDiff("yyyy",[ArrestedDOB],Now())+Int(Format(Now(),"mmdd")<Format([ArrestedDOB],"mmdd")) > 18 Then
Me.ComboName.value = "Value appropriate to test result" 
ElseIf =DateDiff("yyyy",[ArrestedDOB],Now())+Int(Format(Now(),"mmdd")<Format([ArrestedDOB],"mmdd")) <18
Me.ComboName.value = "Value appropriate to test result" 
End If
 
Last edited:
Thanks, John.

I am unable to get it to work. I made some minor changes. Would you mind taking a look at it again to see if any stands out?

Code:
If ((DateDiff("yyyy", [ArrestedDOB], Now()) + Int(Format(Now(), "mmdd") < Format([ArrestedDOB], "mmdd"))) > 18) Then
Me.ArrestedJuvenileAdult.Value = "18 or Older"
ElseIf ((DateDiff("yyyy", [ArrestedDOB], Now()) + Int(Format(Now(), "mmdd") < Format([ArrestedDOB], "mmdd"))) < 18) Then
Me.ArrestedJuvenileAdult.Value = "Under 18"
End If

I appreciate your assistance.
 
What is the actual value your Combo ArrestedJuvenileAdult is actually storing in the underlying table? Is it a numeric value or a text value? if it is a numeric value you will need to replace "18 or Older" and "Under 18" with the numeric values that correspond to those text strings.
 

Users who are viewing this thread

Back
Top Bottom