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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get selected item from subform 1

Status
Not open for further replies.

asanchez4

Programmer
Apr 22, 2004
32
US
I have a form with a subform that is linked to a table.

Once I click on a command button, i need to get the infomration from the highlighted field in the subform.

for example, the subform is based on a table "Customers". The subform is named "Customers subform". I want to be able to highlight one of the customers and then click the command button to get the FirstName and LastName from the selected field in the customers subform.

Any suggestions would be greatly appreciated.

thanks
 
How are ya asanchez4 . . . .
asanchez4 said:
[blue]i need to get the infomration from the highlighted field in the subform[/blue]
Hmmmmm . . . . . Get it to do what? For what what purpose?
Put it in a textbox . . . . . what?

Getting it, is not the problem! We can't help ya unless you tell us what ya wanna do with it!

cal.gif
See Ya! . . . . . .
 
Thanks AceMan1

I have a form based on the table "Units". It has a subform, that is based on "Customers" table. The subform Customers is not linked to the Units form.

When I click the button, I want to take the FirstName and LastName fields of the highlighted instance in the Customers subform and then place those values into the corresponding fields in the Units form.

Thanks again.
 
OK asanchez4 . . . .
[blue]I want to take the FirstName and LastName fields of the [purple]highlighted instance[/purple] in the Customers subform[/blue]
I believe your highliteing first & last name together, side by side. [blue]For the code, you only have to set the cursor in any field on the record.[/blue] Either way, I'm going on the premise that a record is selected with the name fields of interest. If not, you'll have to be more specific about this [purple]highlighted instance[/purple].

The code below should do the job. If not . . . let me know.
Code:
[blue]   Dim frm As Form, sfrm As Form
   
   Set frm = Forms![purple]YourMainFormName[/purple]
   Set sfrm = frm![purple]YoursubFormName[/purple].Form
   
   frm!FirstName = sfrm!FirstName
   frm!LastName = sfrm!LastName
   
   Set sfrm = Nothing
   Set frm = Nothing[/blue]

cal.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top