Getting data from selected record in continuous form

G

Guest

Hello all, I have a subform that is set up as a continuous form, but due to
how the query is set up, the form is unable to make changes. That's not a
problem, as I want to leave it like that, but what I do want to do is find
out how to reference in VBA what the currently selected record is in that
continuous form.

In there is a combo box, and 4 text fields for each record that the query
finds.

If you need anything else let me know.
 
J

John Vinson

Hello all, I have a subform that is set up as a continuous form, but due to
how the query is set up, the form is unable to make changes. That's not a
problem, as I want to leave it like that, but what I do want to do is find
out how to reference in VBA what the currently selected record is in that
continuous form.

In there is a combo box, and 4 text fields for each record that the query
finds.

If you need anything else let me know.

What do you mean by "what is the currently selected record"? You can
view the value of any one of the Controls on the current record by
simply referencing the controlname:

Me!subformcontrol.Form!controlname


John W. Vinson[MVP]
 
G

Guest

Sorry if my question was not clear enough.

Ok if you have a continuous subform, it will list mutliple records on one
page, there will be a selector on the left side that will be highlighted
black to indicate the record that has the current focus for that form.

What I want to know is how to reference the currently selected record in
that subform as I cannot find anything in VBA that seems to fit.
 
J

John Vinson

What I want to know is how to reference the currently selected record in
that subform as I cannot find anything in VBA that seems to fit.

If you are on the mainform, you must use the Name property of the
Subform control (which may be different from the name of the form
within that control); referencing one of the controls on the form
gives you the value of that control *on the currently selected
record*. That is the only record to which you have direct access
(though you can use Move commands to select a different record).

So Me!subformname.Form!txtA will return the value of the control named
txtA in the currently selected record of the Form in the subform
control named subformname.

John W. Vinson[MVP]
 
G

Guest

Thank you much!

John Vinson said:
If you are on the mainform, you must use the Name property of the
Subform control (which may be different from the name of the form
within that control); referencing one of the controls on the form
gives you the value of that control *on the currently selected
record*. That is the only record to which you have direct access
(though you can use Move commands to select a different record).

So Me!subformname.Form!txtA will return the value of the control named
txtA in the currently selected record of the Form in the subform
control named subformname.

John W. Vinson[MVP]
 

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