I need to set the sub-form RecordSource when I open, refresh or up

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am trying to open a form has a sub-form. I need to set the sub-form
recordsource = to mysql statement When I open, refresh or update this form. I
did try:
Forms![mySub-form].RecordSource = mysql
It did not work I am using Access 2003
Thank you for help in advance.
Mike
 
I think that the problem is syntax in your command.

When you open the main form, you should be referring to objects on the main
form using the "Me." prefix. If the control containing the subform is
sfrmSubForm, then you would put

me.sfrmsubform.recordsource = mysql

Also, note that you should be referring to the name of the control on the
main form and NOT the name of the subform itself. For example, the control
containing the subform might be named sfrmSubForm, but the subform itself is
mySub-form (by that I mean that when you look at the list of forms in the
database window, you see mySub-form listed as a form).

Check out http://www.mvps.org/access/forms/frm0031.htm for an excellent
writeup on how to refer to controls and properties on subforms
 
Mike said:
I am trying to open a form has a sub-form. I need to set the sub-form
recordsource = to mysql statement When I open, refresh or update this form. I
did try:
Forms![mySub-form].RecordSource = mysql


In addition to JP's comments, You should set the
RecordSource of the form object, not the subform control.

Forms![mySub-form].FORM.RecordSource = mysql
 
Back
Top