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!

Referencing Columns in a Datasheet Subform 1

Status
Not open for further replies.

Dustman

Programmer
May 7, 2001
320
US
I've got a form with a datasheet subform. I need a command button that will load the input form for the record that is currently selected in the subform. I know you can get the record number from the datasheet but how do I get a particular field number from it? Here are the names:

Main Form: "SearchDonors"
Subform: "SubSearch"
Column Needed: "donorID"
Form Needed to Load: "frmDonorInfo"
frmDonorInfo's recordsource: "Donors" (a table)

donorID is a foreign key to the donorID primary key in Donors.

The subform datasheet is based on a sql query that is built on the fly as the user inputs criteria in text boxes. -Dustin
Rom 8:28
 
To get a specific record when a form (or report) is opened use the Where clause parameter of the DoCmd.OpenForm statement. You can pass the ID selected in the subform to this statement. Use the button wizard to create the button to open the form you want the modify the openform statement using the following syntax (substitute your actual names for the placeholders given):

DoCmd.OpenForm "FormName",,"[IDFieldName] = " & Forms!MainFormName!SubFormName!IDFieldName
 
Hey thanks.. I knew how to open the form.. I just never realized that you could just grab the value of a field name like any other control. I was trying to make it too hard. I am kind of curious why they don't appear in the autocomplete list as you type it like normal controls do. When I use subform.form.donorID it works.. but it doesn't appear in the list for subform.form. Oh well.. as long as it works. :)

-Dustin -Dustin
Rom 8:28
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top