Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subform links fail upon Recordsource change

Status
Not open for further replies.

smandoli9

Programmer
Jun 10, 2002
103
US
Form, 2 subforms (Access 2002)

The Form allows one to change the recordsource of the Form after opening:
Forms("Form").RecordSource = "alt_query"

The record subset for the Form comes out right, but the two subforms look as if they lost their link or did not load.

The new recordsource's query does have the Master Link field, so that's not the problem.

If I return to the original recordsource via the interface, all looks good again.

Following with link rebuild doesn't seem to help:
Forms("Form")!subform_1.LinkMasterFields = "PID_Proj"
Forms("Form")!subform_1.LinkChildFields = "FID_Proj"

I also requery the subforms. No good.

Any ideas?


[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
What happens if you release and recapture the source object for the subforms?

Me.subform_1.SourceObject = ""
Me.subform_1.SourceObject = "YourObject
 

No difference, aside from extra twitching and groaning on-screen.

Right now my code bloat includes
.SourceObject = ""
.SourceObject = "SubForm"
.LinkMasterFields = "PID_Proj"
.LinkChildFields = "FID_Proj"
.Requery

Maybe I'm handling this in the wrong form module. I have a dialog form the user pulls up to construct the filter. It first changes the recordsource if needed. It constructs the SQL and applies the filter. Then it includes the flotsam above. Then the filter form closes, sending focus back to the form-with-subforms.

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Okay I got this resolved. On the main form I had a field for the Master Link. It was bound to [FID_Proj], instead of [PID_Proj]. Fixing this seems to have solved it. [FID_Proj] wasn't a valid source field anyway, but I had this field under another and didn't notice Access was flagging it as a problem.

(PID =primary key, FID =foreign key.)

I've had six-hour bugs before. I've even had six-hour bugs that were stupid. Discovering the issue required rebuilding the form from scratch, and if I had been more rigorous about that (instead of swiping a few fields from my original form!) I could have taken an hour off.

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top