Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selected Item in Subform Datasheet

Status
Not open for further replies.

Tommy408

Programmer
Apr 30, 2006
53
US
How can I get the selected item in a datasheet of a subform?

I've tried:

DoCmd.OpenForm "Contacts", , , "[ID] = [Forms]![Search Customers]![Search Customers Subform]![SubformControlName]", acFormEdit, acWindowNormal
 
DoCmd.OpenForm "Contacts", , , "[ID] =[red] " & [/red][Forms]![Search Customers]![Search Customers Subform]![Red]Form.[/red][SubformControlName], acFormEdit, acWindowNormal
 
It doesn't work.
I probably wasn't clear. The datasheet is on a Form B. And Form A contain Form B as a subform. I need to get the ID of the selected item on the datasheet.
 
Vic's I believe you reversed your bang & dot?
"[ID] = " & [Forms]![Search Customers]![Search Customers Subform]Form![SubformControlName
Where are you calling your code from, we're assuming Form A,
which is the Parent Form?

Me![Search Customers Subform].Form!pkID, should give you the current
record, on the sub form, no matter what method or action
you use it with.

Dim intID as Integer

intID = Me.sfrmWhatever.Form!pkID
 
I guess I should not answer things when I'm in a hurry. Bang and dot are reversed. Thanks Zion!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top