Sorry this is taking so long... Thank you for the help.
Now it is coming up with an error:
"Run-Time error '3464':
Data type mismatch in criteria expression"
I assuming that the two fields it is trying to match up are different
data
types, but I checked and all the fields (In the tables) involved are
set
to
"text". Here is the new code:
Private Sub EarTag_AfterUpdate()
If (DLookup("CalfSex", "tblBirthInformation", "[EarTag]=" &
Me![EarTag]) =
"C") Then
DoCmd.OpenForm "frmTHE"
End If
End Sub
--
Thorson
:
Yes, you can... Dlookup can be used with either!
--
Gina Whipp
"I feel I have been denied critical, need to know, information!" -
Tremors
II
I think I know what the problem is. That query actually requires
that
a
form first be filled in with Parameter Information. So for the sake
of
the
user I think it would be easier to use a table that has the
information
instead, tblBirthInformation, How would the equation change? Can I
just
substitute the query for the table? and the field in the query
(EarTag)
for
the field in the table (CalfEarTag)?
Thank you for your help.
--
Thorson
:
Is EarTag the name of the field in the query and on the form?
--
Gina Whipp
"I feel I have been denied critical, need to know, information!" -
Tremors
II
I tried putting it in the "After-Update" event for the form, but
it
didn't
work. Are there any settings or anything I need to check for?
--
Thorson
:
If (DLookup("Sex", "qryCurrentInventory2", "[EarTag]=" &
Me![EarTag])
=
"C")
Then
DoCmd.OpenForm "frmTHE"
End If
--
Gina Whipp
"I feel I have been denied critical, need to know,
information!" -
Tremors
II
I think that would work fine if they actually had that field in
this
form
where they enter "C" however I want the database to open the
query
and
match
the animal there and see what the field is on the query, not
in
the
current
form the user is entering the data in.
How would I write the code for that? It will have to look up
the
animal's
"EarTag" that was entered into the form in the "EarTag" Field
in
the
query
and then look at the "sex" field for that record.
--
Thorson
:
Here are a couple of ways....
Private Sub Your Field Name Here_Change()
Select Case Your Field Name Here
Case "C"
DoCmd.OpenForm "frmTHE"
End Select
End Sub
OR
Ont the After Update of your field
If ([Your Field Name Here]) = "C" Then
DoCmd.OpenForm "frmTHE"
End If
--
Gina Whipp
"I feel I have been denied critical, need to know,
information!" -
Tremors
II
message
I figured that is what I would need to do. I have written
some
VBA,
but
I've
had lots of help and I haven't done enough to know what I
am
doing.
When an animal is moved, dies or is sold it is entered into
frmDispositionRecordIndID, which is a Sub-form in
frmDispositionRecords.
The
animal's ear tag is entered into frmDispositionRecordIndID
and
the
record
number is automatically pulled from frmDispositionRecords.
After-Update of the EarTag Field in
frmDispositionRecordIndID
I
would
like
the database to look at the query qryCurrentInventory2. If
for
that
animal
the "Sex" field in the qryCurrentInventory2 is "C" I would
like
the
database
to open frmTHE, however if the "Sex" field is "B" or "S"
then
I
would
like
the database to do nothing.
--
Thorson
:
Thorson,
The simple answer is 'Yes'. However, if you require some
assistance
to
make
this happen you might want to provide some details. When
I
want
to
do
something like this I put some VBA on the After_Update of
the
control.
--
Gina Whipp
"I feel I have been denied critical, need to know,
information!" -
Tremors
II
message
Hi, I have a form made from a table
(frmDispositionRecords)
Is
it
possible
that when a user enters an animal in this table a query
could
be
run
and
depending on the sex of that animal in the query a form
will
pop
up
for
the
user to enter information into?