Changing subform SourceObject

C

Chad

I have a subform embedded within a form linked by master and child fields. I
would like to interchange the source object of the subform container,
however, I am constantly getting the error:
***********************************************************
Run-time error '2101':

The setting you entered isn't valid for this property.

***********************************************************

Below please see different things I have tried to get this to work:

Method 1 (I get the error above and it refers to this line of code):

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].SourceObject =
"sfrmCheckDetailUpdate"

Method 2 (I do not get the error but the subform is blank)

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].SourceObject =
sfrmCheckDetailUpdate

Method 3 (I get the above error when referring the master or child fields)

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].SourceObject =
sfrmCheckDetailUpdate

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].LinkChildFields = "DISB_ID"
Forms![frmDisbursementEdit].[sfrmDisbursementEdit].LinkMasterFields =
"DISB_ID"


Any insight as to why this is happening would be greatly appreciated.

Thanks!
 
C

Chad

Marshall,

Thank you for your response. I have also tried the code you provided and it
still returns the error described below and stops on the .LinkChildFields
line. I am not sure what is causing this but for the time being I am just
putting a bunch of subforms on the Main form and setting them as visibile or
not visible based on the actions fo the user.

However I would like to get the SourceObject functionality working if
possible. Any further ideas as to what could be causing this would be
greatly appreciated.

Not sure if it helps, but I am using 2007.

Best,
Chad

Marshall Barton said:
Chad said:
I have a subform embedded within a form linked by master and child fields. I
would like to interchange the source object of the subform container,
however, I am constantly getting the error:
***********************************************************
Run-time error '2101':

The setting you entered isn't valid for this property.

***********************************************************

Below please see different things I have tried to get this to work:

Method 1 (I get the error above and it refers to this line of code):

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].SourceObject =
"sfrmCheckDetailUpdate"

This is the correct way to do that.
Method 2 (I do not get the error but the subform is blank)

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].SourceObject =
sfrmCheckDetailUpdate

This is nonsense and if you have OPTION EXPLICIT in the
module, you should get an undefined variable error.
Method 3 (I get the above error when referring the master or child fields)

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].SourceObject =
sfrmCheckDetailUpdate

Forms![frmDisbursementEdit].[sfrmDisbursementEdit].LinkChildFields = "DISB_ID"
Forms![frmDisbursementEdit].[sfrmDisbursementEdit].LinkMasterFields =
"DISB_ID"

That's close, but the existing LinkMaster/Child Fields are
probably in conflict with the new subform. Try clearing
them first:

With Forms![frmDisbursementEdit].[sfrmDisbursementEdit]
.LinkChildFields = ""
.LinkMasterFields = ""
.SourceObject = "sfrmCheckDetailUpdate"
.LinkChildFields = "DISB_ID"
.LinkMasterFields = "DISB_ID"
End With
 

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

Top