Open Form depending on criteria

T

Thorson

I have a form where information is entered when an animal leaves the group
due to death, euthanization, transfer or sale. On the After Update event of
the field "DispMethod" I would like a form "frmDamProductivity" to open if
the text entered is either Died, Euthanized or Sale AND if the age is <548
Days. Can I also have it calculate the age from the field "BirthDate" in
tblBirthInformation?

Can someone help me set this up?
Thanks.
 
B

Beetle

To calculate the age in days you could add an unbound text
box to your form with a Control Source of;

=DateDiff("d", [BirthDate], Date())


To open the other form, use code like;

Private Sub DispMethod_AfterUpdate ()

If Me!DispMethod = "Died" Or _
Me!DispMethod = "Euthanized" Or _
Me!DispMethod = "Sale" Then
If DateDiff("d", [BirthDate], Date()) < 548 Then
DoCmd.OpenForm "frmYourForm"
End If
End If

End Sub
 
T

Thorson

I entered in the following code but I must be doing something wrong... It is
a little different than yours since I decided to look up the age in days from
a query I previously created. Does it matter that txtDispMethod is on the
main form and that txtEarTag is on a subform?

Private Sub txtEarTag_AfterUpdate()
If Me!txtDispMethod = "Died" Or _
Me!txtDispMethod = "Euthanized" Or _
Me!txtDispMethod = "Sold" Then
If (DLookup("Age(Days)", "qryCurrentInventory2AllAnimals", "[EarTag]='" &
Me![EarTag] & "'") < 549) Then
DoCmd.OpenForm "frmCalfDisposal"
End If
End Sub

Thanks!
--
Thorson


Beetle said:
To calculate the age in days you could add an unbound text
box to your form with a Control Source of;

=DateDiff("d", [BirthDate], Date())


To open the other form, use code like;

Private Sub DispMethod_AfterUpdate ()

If Me!DispMethod = "Died" Or _
Me!DispMethod = "Euthanized" Or _
Me!DispMethod = "Sale" Then
If DateDiff("d", [BirthDate], Date()) < 548 Then
DoCmd.OpenForm "frmYourForm"
End If
End If

End Sub

--
_________

Sean Bailey


Thorson said:
I have a form where information is entered when an animal leaves the group
due to death, euthanization, transfer or sale. On the After Update event of
the field "DispMethod" I would like a form "frmDamProductivity" to open if
the text entered is either Died, Euthanized or Sale AND if the age is <548
Days. Can I also have it calculate the age from the field "BirthDate" in
tblBirthInformation?

Can someone help me set this up?
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top