Connecting Tech Pros Worldwide Help | Site Map

Synchronizing Two Subforms

Tom
Guest
 
Posts: n/a
#1: Nov 12 '05
The purpose of my form is to record multiple owners of businesses. The main form
displays the business records. Subform1 is a continuous form consisting of only
a combobox to select owners from a table of owners. Subform1 contains record
selectors so after owners are entered, a specific owner can be selected. PK is
OwnerID. Subform2 is a single form based on the same owner table and its purpose
is to display details about the selected owner in Subform1. Foreign key is
OwnerID.

Since Subform1 is a continuous form, I have Subform2 external to Subform1. What
needs to be done so that as specific owners are selected in Subform1, Subform2
displays the related details about the owner selected inSubform1?

Thanks,

Tom


paii, Ron
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Synchronizing Two Subforms


Why don't you make subform 1 the main from and link subform2 (Detail
records) to the main form on OwnerID?

"Tom" <tharkless@bellsouth.net> wrote in message
news:U_rpb.3584$Oo4.1037@newsread1.news.atl.earthl ink.net...[color=blue]
> The purpose of my form is to record multiple owners of businesses. The[/color]
main form[color=blue]
> displays the business records. Subform1 is a continuous form consisting of[/color]
only[color=blue]
> a combobox to select owners from a table of owners. Subform1 contains[/color]
record[color=blue]
> selectors so after owners are entered, a specific owner can be selected.[/color]
PK is[color=blue]
> OwnerID. Subform2 is a single form based on the same owner table and its[/color]
purpose[color=blue]
> is to display details about the selected owner in Subform1. Foreign key is
> OwnerID.
>
> Since Subform1 is a continuous form, I have Subform2 external to Subform1.[/color]
What[color=blue]
> needs to be done so that as specific owners are selected in Subform1,[/color]
Subform2[color=blue]
> displays the related details about the owner selected inSubform1?
>
> Thanks,
>
> Tom
>
>[/color]


andybriggs
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Synchronizing Two Subforms



The general idea is to set the RecordSource property of Subform2 to
select the one record that matches the record in Subform1. When a record
is selected in the control on Subform1, attach a procedure to its
"AfterUpdate" event to select the record in Subform2. It would look
something like:



Sub Subform1ControlName_AfterUpdate()



Forms!NameOfMainForm!NameOfSubform2.Form.RecordSou rce = _

"SELECT * FROM NameOfTableOrQuery WHERE OwnerID = " _

& Forms!NameOfMainForm!NameOfSubform1.Form! ControlNameInSubform1



End Sub





This selects the one record in Subform2 that matches the OwnerID
selected in Subform1. Donīt forget that if the OwnerID is text then you
need to modify the SQL slightly to read :



Forms!NameOfMainForm!NameOfSubform2.Form.RecordSou rce = _

"SELECT * FROM NameOfTableOrQuery WHERE OwnerID = ī" _

&Forms!NameOfMainForm!NameOfSubform1.Form! ControlNameInSubform1 &"ī"



I hope this helps.


--
Andy Briggs
Elmhurst Solutions Limited
http://www.elmhurstsolutions.com


Posted via http://dbforums.com
Closed Thread


Similar Microsoft Access / VBA bytes