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

Updating a subform field - selecting field to update from dropdown

Status
Not open for further replies.

jkafer

Technical User
Feb 13, 2004
32
US
I am trying to create a form that allows me to select a table, then select 2 fields to update. The updating is done with vb code (there are a couple of different things that will be done). Here are the basics:

Form has 3 dropdown boxes on it:
fldT - list of tables available (fills on form open) - ok
OnChange - updates the next two dropdowns with field lists
fldO - Field with data to be processed/updated
fldD - Field to put the processed/updated data

Form also has a subform, subFixData, which displays the table that is selected with the fldT dropdown.

All of these work great!!! (thanks to your wonderful forums).

The problem I am having is accessing the data in the subform. I keep getting the message "Can't find the field 'Name' referenced in your expression"

A simple edit that I may need to do is this:
fldT = tblNames
fldO = Name
fldD = PName

I am at a loss to reference these fields in that subform.

I know it's something simple, but I can't see it.

Any and all help is greatly appreciated.

Jeni K
 
"Can't find the field 'Name' referenced in your expression"
Which expression ?
You can try something like this:
Forms![MainForm]![ControlNameOfSubForm].Form.Controls![ControlName]

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Here is what I think the problem is:

The field in the subform is a variable, selected from the dropdowns. So I don't know of a way to write the line to reference that field.

The subform is displaying a table, not a form. Because the tables that are available to select have different structures. That's why I have the second drop downs that load the field list once the table is selected from the first drop down.

Forms![MainForm]![ControlNameOfSubForm].Form.Controls![ControlName]

'[ControlName]' is a variable - selected from the dropdown.

Does that make any better sense?

JK
 
Have you tried this ?
Forms![MainForm]![ControlNameOfSubForm].Form.Controls(theVariable)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That did it!

Thanks for the help!!!

~~~~~~~~~~~
Jeni K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top