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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't set recordset to a SubForm.

Status
Not open for further replies.

softlover

Programmer
Apr 4, 2002
88
0
0
CN
I want to set recordset for a subform in a mainform. I tried the codes likes below.
Set [Forms]![FrmMain]![FrmSub].Recordset = MyRst
But it doesn't work.
 
I tried the codes likes below.
Set [Forms]![FrmMain]![FrmSub].Form.Recordset = MyRst
But it also doesn't work.
 
Can you define "doesn't" work? Error#/msg, what happens that shouldn't happen and vice versa...

Of the top of my head, the most usual reason for subform referencing not working, is that the subform control, which is what one references, is named something other than the subform. Easiest way of obtaining the correct name, would be to invoke the expression builder from a control on the main form, then doubleclick through forms, loaded forms, the main form, the subform, and a control on the subform. This will give a reference like

[SubformControlName].Form![txtControlName]

Strip to

Set Me![SubformControlName].Form.Recordset = MyRst

If this doesn't work, then there is probably something else making trouble, perhaps the link child/parent properties of the subform control? Dunno - try it out, and check back with more information.

Roy-Vidar
 
Thanks to RoyVidar. I tried the following codes and work fine.
Me.SubForm.Form.Recordset = MyRst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top