Iif Statement

  • Thread starter Thread starter Thorson
  • Start date Start date
T

Thorson

I have a form that records a calf's birth information, in that form the user
enter's the sire of the calf (cboSire), they are also suppose to check a
yes/no box as to whether or not the calf is an AI Calf (txtAI). In a
separate table (tblSireListing) all the sires are listed and a Yes/No box is
listed if the sire is an AI Sire.

I would like to put an if statement in the event section after update for
cboSire, but I need help writing it since I am new at this. I would like to
do the following:

If the sire listed in the cboSire on the form is in the tblSireListing and
the Yes/No box is checked "Yes", Then txtAI on the form will check "Yes", if
it is not checked and is therefore "No" then the txtAI box on the form will
remain blank.

Can someone help me write this statement?
Thank you
 
Hi,

Firstly you need to return AISire in the recordsource of the combobox. You
may then check it's value by;
txtAI = Me.cboSire.Column(X) where X is the column number. The columns are
numbered from zero, so if AISire is the second column then it's number is 1.

Regards
 
cboSire has the record source set to Sire (a list of all the sires) in
tblSireListing; txtAI has the record source set to AI (a check-box yes/no) in
tblSireListing, this is the 6th column in the table, therefore number 5.

I put in the following code on the "after update" event for cboSire
txtAI = Me.cboSire.Column(5)

However when I did a test and put in a sire for cboSire (that had the
checkbox checked in tblSireListing), nothing happened to txtAI in the form.

Did I type something in wrong? or do I have something set up incorrectly?
 
Thanks for the help! It does look like it would be better to do a
relationship, we can see how it works out.

AI Calf was not a field name, neither was AI Sire, I must have implied they
were fields. I don't put spaces in my field names, but thank you for the
reminder.
 
Back
Top