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

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
 
J

JP

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
 
M

Marshall Barton

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
 

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