Controlling two SUBFORMS on one form

A

Ayo

I have this form with 2 subforms on it. The 2 subforms a pretty much the
same except the records in one is actual dates and the other contains
forecast dates. I want to be able to control both subform from one subform.
For instance, when I scroll down in the top subform I want the bottom one to
scroll the same records; just like in excel's side-by-side comparison. Is
there a way todo this in access?
Thanks for the help.
 
A

Arvin Meyer [MVP]

In the first subforms Current event something like (untested):

Private Sub Form_Current()
Me.Parent.SecondSubformName.Form.txtID = Me.ID
End Sub

Where txtID is the name of the textbox holding the ID and ID is the field
name of the ID field.
 
A

Ayo

I don't think subforms have a current event. And I don't really understand
the part about "textbox holding the ID and ID is the field name of the ID
field."
 
A

Arvin Meyer [MVP]

A subform is a form. A subform control is the container on the form that
holds the subform. A textbox is a container which holds a field, but it can
also be unbound to any field. The subform control has only 2 events, but the
subform itself is a form which has all the form events, including the
Current event.

Forms do not have fields, they have controls. Sometimes a field and a
control have the same name. This can confuse both the user and even Access
if square brackets are not used.

So in my example ID is the name of the Primary Key field in the table: txtID
is the name of a text box. ID is the name of the field it contains. Many
good developers differentiate the 2 so there won't be any confusion. When
building a form by dragging the fields or by using the wizard, Microsoft
defaults the name of the control to the name of the field. I rename the
control for clarity, and indeed I have a free utility which does it
automatically:

http://www.datastrat.com/Download/FixNames2K.zip

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

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

Similar Threads

If field =15 save in two tables 2
Link Two Subforms on a Main Form 1
Sync two subforms 1
Subform record coordination 2
linking to two subforms 2
SubForms 4
Forms and subforms 2
Form multiple subforms? 3

Top