OK - I think I have a working picture of your form setup in my mind. I am
assuming that the name of the subform control is [advancement Subform]. This
would be the name of the subform control if you open the main form in design
view, click on the very top edge of the subform control, open the Properties
window, and click on the Other tab and read the Name value. If it has a
different name, change the code/info below to the correct name.
Do these steps:
(1) Delete the event procedure and code from your AdvSel control's GotFocus
event.
(2) In some situations, naming a control the same name as the name that is
in its Control Source is ok. In this case, I would change the name of your
"Rank" combo box on the main form to cboRank, as a field and combo box have
different properties and we can better avoid confusion if we name the combo
box something else.
(3) Change the Row Source SQL statement on the subform's combo box to this:
SELECT Advancement_code.[Advancement Code],
Advancement_code.[Advancement Description],
Rank.[Rank description], Rank.Rank FROM Rank
INNER JOIN Advancement_code ON
Rank.Rank=Advancement_code.[Current Rank]
WHERE (((Rank.Rank) Like Forms!AdvancementMaster!cboRank))
ORDER BY Rank.[Rank description];
(4) Use this code on the AfterUpdate event of the cboRank combo box (this
will cause the combo box on the subform to requery whenever you make a
change to the combo box named Rank):
Private Sub cboRank_AfterUpdate()
Me![advancment Subform]!AdvSel.Requery
End Sub
(5) Use this code on the Current event of the main form(this will cause the
combo box on the subform to requery whenever you move from one record to
another in the main form):
Private Sub Form_Current()
Me![advancment Subform]!AdvSel.Requery
End Sub
This should do what you seek.
By the way, I'm not ignoring your comments regarding your willingness to
email me a copy of your database. That usually is not necessary for most
newsgroup questions, and if we get to the point where I feel I must see the
database to figure out what is happening, I'll indicate that I'd like to see
it. By staying within the newsgroup to explain/suggest things helps people
learn how to explain what they're doing, and for others (me included) to
learn how to "see" what a person is explaining. I am a firm believer that
people learning ACCESS (or becoming more proficient at it) need to
understand what they have in a form or report, and how it is/is not working,
and to be able to explain that in a meaningful way, in order to gain
significant "hands-on" capability with the software. Having someone "edit" a
database and return it with the fixes may be a final outcome, but it usually
doesn't help both parties progress in their abilities and understanding. (I
say this as a person completely self-taught in ACCESS -- a person who
eschewed the wizards for most features after the first few weeks because it
was too difficult to figure out how they created what they created and how
they worked.)
Let me know if the above changes are what you seek! < g >
--
Ken Snell
<MS ACCESS MVP>
Rpatton@cpsbiz.com said:
Good Morning Ken,
I will try to answer your questions the best I can.
I think you have it right, but just to be sure i will repeat it back with
the details you requested.
(1) the name of the subform control (the actual control that holds the
the combo is AdvSel
is a query called
AdvCodeQuery - That the SQL i sent the first time.
More info:
the AdvancementMaster form contains 6 controls, (each is a field in the
participant table) ID (the key), name, Den Number, Rank, Home Unit, and
Age.
"Rank" is both the Control Source and Control Name name (should they be
differant, i have always wondered). The user chooes a Scout and the and
the
rank control now contains that scouts rank.
The sub form cantains the advancment information (ID, record Number,
Advancment Code, and date (not rank)). This info is in the advancement
table. Each record forms a link between the participant table and the
Advancement code table. (I will e-mail the structure to you)
In the sub form (called advancment Subform, it is in table view) there is
a
field called Advancement code. This code is selected based on a combo box
called AdvSel (that is where the query AdvCodeQuery is located). So when
the
user selected a participant the sub form which is keyed to ID now contains
all information needed to create an advancment record except the
Advancement
code. The user now selects the AdvSel combo box, and is presented with a
list of advancement codes for the rank, derived from the Rank related to
that
scout id on the main form (the control name and control source is Rank,
but
this time it's the rank from the query AdvCodeQuery ). The user clicks an
advancment code and a record is added to the Advancement table. The user
may
then choose another advancement for this scout or go to the main form and
choose another scout.
I hope i have not confued you more, it's so simple whent you see a
picture,
again i will try to e-main the structure to you at your address shown on
the
site.
This is so good of you to take this time. I am sorry to be a pain, i hope
i
answered all of your questions.
Dick