Subforms and Events

G

Guest

After reading through a number of Newsgroup dialogue's I've 'almost' got my
problem licked. A little more help at this stage would really be appreciated.

I have several subforms that I've linked to a master/parent form and this
all seems to be working well. What I am now trying to do is to be able to
change a field ('PetType') in one subform ("A") and then when I click on the
tab to go to a different subform ("B") it will read the changed field and
either hide or unhide some of the controls on the form ("B"). Part of the
code I've written to do this looks like:
If Forms!SPCA!PetInfo.Form!PetType = "Dog" Then
Me.CatFIVFeleukCombo.Visible = False
Me.CatFVRCP.Visible = False
Me.CatFeleukVacc.Visible = False
Me.FEBOOSTER.Visible = False
Me.DogDHLPP.Visible = True
Me.DogKenCough.Visible = True
End If

This code is in the On Current event in "B". PetInfo is subform "A".

My problem is that the 'visible' code lines above work fine when I first go
into a record but nothing changes when I'm actually in the record on subform
'A', change the PetType field and then use the tab to go to subform 'B'.

I've experimented with docmd.requery and me.requery, placing them in various
other events, but don't seem to be able to get it quite right.
 
G

Guest

I'm 'somewhat' answering my own question so that others may benefit from the
hours I've put in trying to resolve my problem. Despite what I understand
'should have' worked, code placed in the On Activate event of a subform (in a
tabbed section) simply did not work. In fact, I experimented by placing
lines like " 'debug.print 'on activate' " in many of the form events and
couldn't even get it to print those for me (which I interpret to mean that
the events were never triggered...even some that I thought would, like On
Current and On Activate).

To resolve my problem, I made sure I knew which field was the first to be
recognized in the subform (by looking at the Tab Order) and then placed all
of the event code in the 'On Got Focus' event. This worked like a
charm...and I should have thought about it hours ago....
 

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