467,134 Members | 1,059 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

Trigger an action by highlighting a row in a subform

So I think this may be a stretch, but I have a subform that is
displayed on a main form. The subform is based on a query that brings
records from a table(It does not bring all fields, but the main
identifiers, since there would be too many to be able to display). The
user specifies criteria on the form, which narrows down the number of
records shown in the subform. Underneath the subform, there is another
subform that consists of 25 fields, but displayed in form view as
opposed to datasheet view(this way, only one record is shown at a time,
but I can display more data on the single form. Is there any way that
someone can simply highlight one of the many records from the first
subform, and the info for the fields specific to that record will then
be shown in the other subform??? This was hard to explain, so I hope
it makes sense.

Thanks,

Matt

Nov 13 '05 #1
  • viewed: 2119
Share:
3 Replies
On 1 Mar 2005 12:16:07 -0800, ma************@eaton.com wrote:
So I think this may be a stretch, but I have a subform that is
displayed on a main form. The subform is based on a query that brings
records from a table(It does not bring all fields, but the main
identifiers, since there would be too many to be able to display). The
user specifies criteria on the form, which narrows down the number of
records shown in the subform. Underneath the subform, there is another
subform that consists of 25 fields, but displayed in form view as
opposed to datasheet view(this way, only one record is shown at a time,
but I can display more data on the single form. Is there any way that
someone can simply highlight one of the many records from the first
subform, and the info for the fields specific to that record will then
be shown in the other subform??? This was hard to explain, so I hope
it makes sense.

Thanks,

Matt


Yes - it can be done, but you have to watch for contention issues between the
subforms if editing is allowed on both (or somethines even if it isn't).

The Current event fires on a form each time you move to a new record, and you
can use that to trigger a re-sync of the other subform. There are 2 gotchas
here, though.

1. Subforms are initialized before the parent forms, so your code can crash
the first time you try to process the Current event on the subform.

2. Sometimes, the Current event can fire before the recordset is opened, so
your Current event handler can crash trying to read data from the current
record the first time it fires.

I'll post back later when I have more time about strategies for working around
these gotchas.
Nov 13 '05 #2
ma************@eaton.com wrote in
news:11**********************@o13g2000cwo.googlegr oups.com:
So I think this may be a stretch, but I have a subform that is
displayed on a main form. The subform is based on a query
that brings records from a table(It does not bring all fields,
but the main identifiers, since there would be too many to be
able to display). The user specifies criteria on the form,
which narrows down the number of records shown in the subform.
Underneath the subform, there is another subform that
consists of 25 fields, but displayed in form view as opposed
to datasheet view(this way, only one record is shown at a
time, but I can display more data on the single form. Is
there any way that someone can simply highlight one of the
many records from the first subform, and the info for the
fields specific to that record will then be shown in the other
subform??? This was hard to explain, so I hope it makes
sense.

Thanks,

Matt

Try this: On the main form create a textbox. It can be invisible,
it will still work. In the first subform set the On Current event
to put the Primary key of the record into the textbox*. Now Set
the Link Master Fields property of the second subform to the
textbox on the parent form. and the Link Child Fields to the
foreign key in your subform.If you don't want to use the on
current event, use the on click events of each field AND of the
detail section of the form

*parent!txtbox.value=me!pkfield.value is what I use, with names
adjusted to suit..

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #3
So I did exactly what you said. I created the On Current command of the
first form, which sets the value of an unbounded text box on the main
form. I then linked the unbounded text box to the foreign key of the
second subform. After doing this, I can highlight a record on the first
form, and its key value will appear in the text box. However, the
second subform does not change at all. Any Ideas?
Matt

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Scott CM | last post: by
1 post views Thread by Simon Holmes | last post: by
5 posts views Thread by William of Ockham | last post: by
reply views Thread by JohnO | last post: by
2 posts views Thread by Keith Wilby | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.