Understanding Subforms

  • Thread starter Thread starter Newbee
  • Start date Start date
N

Newbee

I have a question (this may have been posted earlier)

I have three forms - Master, Tabular and Columnar

From my Master, I have a command button that switches the
subform from Tabular to Columnar.

Why, after clicking the command button, does the subform
turn white?

thanks
 
You don't post your code as to how the switch occurs.

Further, likely, you might have to correctly setup the link master, and link
child fields when you change the source of the sub-form control.

Also, those sub-forms are based on a table that is a child table, or related
table to the master...right?
 
If cmdView.Caption = "Form View" Then
subFrmView.SourceObject = Form_frmContactCopyof
cmdView.Caption = "Table View"

Else
subFrmView.SourceObject = Form_frmContact2
cmdView.Caption = "Form View"

End If
 
Newbee said:
If cmdView.Caption = "Form View" Then
subFrmView.SourceObject = Form_frmContactCopyof
cmdView.Caption = "Table View"

You are actually replacing the object by making reference to another
object.You do NOT want to use the form_YourFromName reference here.

(the above will cause all kind of problems). In fact, when you ref
form_YourFormName, the form actually loads..and all the events etc fire.
This "copy" that loads will not even been set into the sub form).

Remember, a sub-form on a form is NOT really a sub-form, but simply a
control. You can have a text box control on a form called

zoo

You can then set the data source of that control to any field on the forms
underlying record set.

The same concept applies to a sub-form control....you only have to change
the form NAME of the form that control is supposed to show.

To make a long story short..the SouceObject prootery of a sub-form contorl
is a text (string) seeting. So, you only need to stuff in a string value.

So, to change what form a sub-form contorl uses, you should use:

me.subFrmView.SouceObject = "frmContactCopyof"

Do NOT use the base object of the forms like form_YourFormName

(In fact, if you have this format for "Form_YourFormName" used anywhere in
code...you should remove it)
 
Back
Top