change recordset

G

Guest

I've got a sub-form inside a form for which I want to change the recordset
from within VBA. (The sub-form has no recordset for itself and I wish to use
the same sub-form for several different queries, depending on which button is
pressed).

The line I currently am trying is

Me!pos_in.Recordset = "pos_same" where pos_in is the subform and "pos_name"
is the query I wish to use. The system rejects this line, but it likes

Me!pos_in.SourceObject = "pos_in_fimat"

which apparently changes the sub-form, not the recordset. How can I change
the recordset associated with that sub-form? TIA.....
 
J

John W. Vinson

I've got a sub-form inside a form for which I want to change the recordset
from within VBA. (The sub-form has no recordset for itself and I wish to use
the same sub-form for several different queries, depending on which button is
pressed).

The line I currently am trying is

Me!pos_in.Recordset = "pos_same" where pos_in is the subform and "pos_name"
is the query I wish to use. The system rejects this line, but it likes

Me!pos_in.SourceObject = "pos_in_fimat"

which apparently changes the sub-form, not the recordset. How can I change
the recordset associated with that sub-form? TIA.....

I think you want

Me!pos_in.Form.Recordsource = "pos_name"

The Source Object is the name of a Form used within the subform control; that
Form has a Recordsource (not Recordset!) property which is the name of a
table, of a query, or is a SQL string.

John W. Vinson [MVP]
 
M

Marshall Barton

J. Freed said:
I've got a sub-form inside a form for which I want to change the recordset
from within VBA. (The sub-form has no recordset for itself and I wish to use
the same sub-form for several different queries, depending on which button is
pressed).

The line I currently am trying is

Me!pos_in.Recordset = "pos_same" where pos_in is the subform and "pos_name"
is the query I wish to use. The system rejects this line, but it likes

Me!pos_in.SourceObject = "pos_in_fimat"

which apparently changes the sub-form, not the recordset. How can I change
the recordset associated with that sub-form? TIA.....


Me!pos_in.Form.RecordSource = "pos_same"
 

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