Changing Source Object

  • Thread starter Thread starter Melba via AccessMonster.com
  • Start date Start date
M

Melba via AccessMonster.com

I have a main form frmAdmin with a subform "sContacts" on it. I need to
change the subform object to bring in another subform name 'sfrmProfile" But
it's not changing. I'm not linking anything because I'm bringing in ALL the
records.

Now it works fine when I manually go into the design mode and change the
object to sfrmProfile and then run the form ,the form shows the correct
records.

Please help. Here is my code in the click of the "Profile" button on click
event I have the following code:
Forms![frmAdmin]![sfrmProfileSub].SourceObject = "sfrmProfile"

error message = can't find the field sfrmProfilesub

I'm totally confused. I'm also ready to just use the button to a docmd.
openform and open each form in a pop-up upon click of the button, but I know
there's a neater way. Please help.

Melba
 
Open your main form in design view.
Right-click the edge of the subform control, and choose Properties.
On the Other tab of the Properties box, what is the Name of the subform
control? It may be different from the name of the form you are trying to
load into the subform control.

Other traps when changing SourceObject:
1. It may not work if the current record is dirty and cannot be saved
(assuming it's a bound form.)

2. Access might assign some irrerelvant thing to the LinkMasterFields and
LinkChildFields when you change subform.

Try:
If Me.Dirty Then Me.Dirty = False
With Me.sfrmProfileSub
.SourceObject = "sfrmProfile"
.LinkMasterFields = vbnullstring
.LinkChildFields = vbNullString
End With
 
Back
Top