Populating Fields in a Form- Help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to get one field in a form to populate a certain value based on
the values of other fields in the form. I want to use an "if, then"
expression but it is not working. I need to know specifics: where do I enter
the expression, (i.e. if in Properties, in which field? If in Expression
Builder, what do I enter in exactly?) the field that I am using as criteria
are all combo boxes, does that make a difference? and what type of field
should the field I am trying to populate be (I have it as a combo box because
I would like it to select one of the three values based on the criteria from
the other three fields). I am using Access 2000
 
That wasn't really what I wanted to do, but it was interesting. I want the
second field to populate automatically with a preset value based on the
criteria from the first field. I just don't know if it is possible...
 
I think that you're talking about something that can be handled with Select
Case:

You have a field that you enter information into and once that is entered
you want another field to be automatically populated with related data. So if
you type "Terrier" into one field you want the other field to be set to
"Dog". Use the AfterUpdate event of the first control to accomplish this. See
the code below....


Private Sub MyTextBox_AfterUpdate()
Select Case Me.MyTextBox
Case "Terrier"
Me.[MyTargetField] = "Dog"
Case "Siameze"
Me.[MyTargetField] = "Cat"
Case "Heifer"
Me.[MyTargetField] = "Cow"
Case "Fawn"
Me.[MyTargetField] = "Deer"
End Select
End Sub
 
Back
Top