Jason
Jason

Reputation: 506

Getting CurrentRecord from a table in a subform

I have a company form that list their basic info with a subform tab that list more company info like contacts, parts and orders. I use a tab control where each tab has a table with basic info about each. I am trying to open another form that has detailed information about the user highlighted row in the table, but cannot figure out how to read which row is selected.

The form is call Customer, the tab form is called tabDetails, the parts tab is caled tabParts and the table that lists all the parts for the company is called tblPartsList.

This is what I thought would work.

ID = Me!tabDetails!tabParts!tblPartsList!CurrentRecord![ID]

Upvotes: 1

Views: 58

Answers (3)

Santosh
Santosh

Reputation: 12353

You can use ActiveControl property to refer to the control that has the focus at runtime

ID= Screen.ActiveControl.Parent("ID")

Upvotes: 0

Jason
Jason

Reputation: 506

The solution that I found to work was just to call the table control.

ID = tblPartsList![ID]

Thanks for everyone's help.

Upvotes: 1

Gustav
Gustav

Reputation: 55961

Use the Form property of the subform control.

tabDetails here is the name of the subform control:

ID = Me!tabDetails.Form![ID].Value

or:

ID = Me!tabDetails.Form!tblPartsList.[ID].Value

The form's tabs are only for ordering the controls. They are not containers for these.

Upvotes: 0

Related Questions