Forms and sub forms

M

Mike Green

Hi All
I have just been asked to help with a Db that records animal details.
There is an input form that has two subforms in it, one subform becomes
visible if Female is selected from the main form and the other subform
becomes visible if Male is selected on the main form. There appears to be
no actual link within the Db itself that can be used to show the correct sub
form when the user scrolls through the records.
Does anyone have any pointers on how I could get the correct sub form to
appear based on the information that has been previously saved into the Db?
I think it could be done on an Event Procedure but I am not sure which event
to use so that when a new data set appears in the form the event will
display the correct sub form. (the subform works fine when collecting new
data as there is already an event procedure for the afterupdate event on the
FdAnimalSex, its just the bit when scrolling through existing records that I
can't remember how to do)

Thanks in advance

Mike
 
A

Al Campagna

Mike,
Several ways to this this... basically...
Let's say the main form contains a text control (or chkbox, or lisbox, etc..) bound to
field Sex, and that field can have a value of "M" or "F".
On the OnCurrent event of the form...
If Sex = "M" Then
Me.subFemale.visible = False
Me.subMale.Visible = True
Else
Me.subFemale.visible = True
Me.subMale.Visible = False
End If

Also, use that same code in the AfterUpdate event of Sex.

A simpler version of that same code...
Me.subFemale.Visible = Sex = "F"
Me.subMale.Visible = Sex = "M"
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
M

Mike Green

Thanks Al
I knew there was a way just could't remember the trigger!

Thanks again

Mike
 

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