Reference selected datasheet field on subform from mainform

Posted on 2013-10-02
Medium Priority
Last Modified: 2013-10-02
Hi All,

I have a hopefully simple question, but I just can't work it out! (too late!)

Main form frmHeader has a subform, sbfDetail_DS, which is in datasheet view. On a button on the main form, I need to reference the selected det_id value on the subform. How can I do this?!

Set frm = Forms!frmHeader!sbfDetail_DS.Form
Debug.Print frm.CurrentRecord 'gives correct value: of selected row (base 1)
Debug.Print frm!det_id.Value 'Always gives the value of the first row, not the selected row

Open in new window

Many thanks!
Question by:katerina-p
  • 2
LVL 50

Accepted Solution

Dale Fye earned 2000 total points
ID: 39541789
syntax is generally:


Make sure you are using the subformControlname, not the subform source object (although they can be the same), and generally are by default.  This should work, use the dot, not the bang between "Form" and the control you are trying to get.


Author Closing Comment

ID: 39541867

LVL 50

Expert Comment

by:Dale Fye
ID: 39541948
glad I could help

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Audit trails are very important in any system to hold people responsible for certain transactions and hold them to take ownership of their actions. This article is dedicated to all novice "Microsoft Access" developers.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question