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

accessing fields on sub forms from table data 2

Status
Not open for further replies.

davejam

Technical User
Jan 6, 2004
313
GB
I am trying to update fields within subforms, but have to reference them as the full string as it could be one of many locations (ie. forms!mainform!subform.form.Field1 = value)

I have the form and field references stored within a table (using templates so could be differenct updates for each client)

my trouble is trying to reference the field when my references are variables and not text.

If i wanted to update InvoiceAddress on subform1 within form1 with a value after a field is updated this would be stored in a table like, just for example;

fields: stored values
fForm: form1
fSubForm: subform1
fField: InvoiceAddress
fvalue: 3

how do i get it to poulate this in code, tried building the string and then referencing it as
forms(myFormString) = fvalue
but it came up with either data mismatch or no errors, just didn't perform update!!

Tried updating using values or text (instead of the reference fvalue just in case) but still, either errors or nothing and doesn't seem to change anything!!!

Is there any way of acheiving this, i do have other tasks i need to perform using references from a field within a table, like refer to a 'column(1)' from a form field again stored within a table.

also wanting to change a recordsource of a combo, but referencing the .recordsource as 'recordsource' via a stored field within a table. (i need this table to perform many tasks to manipulate the input forms)

Hope this makes some sence, cheers in advance for ANY help.

Any pointers very welcome....

Cheers



daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
How about:

[tt]Forms(fForm).Controls(fSubForm).Form.Controls(ffield)=fvalue[/tt]
 
That worked a treat, cheers, but i am still struggling on refering to specifics with some aspects of the field.

i also store fCtl so i can either refer to a column from a combo box to update with, or so i can set a recordsource within another field

fCtl: column(1)

so for the first statement i need to get a column from the field using the variable from the table.

so now i'm refering to fValue as a field within my current form like me(fValue).control(fCtl)

doesn't seem to work for me, but i hope it is something as easy as this;

Forms(fForm).Controls(fSubForm).Form.Controls(ffield)=me(fvalue).control(fCtl)

Just having a play with it....

daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
You might find Eval useful:
MsgBox Eval("Forms!" & fForm & ".[" & fSubForm & "].Form." & ffield)
 
I couldn't end up doing everything that i wanted to ie. selecting the column from my record, but instead managed to say .column(field), and so have found a work around for this and other properties.

Enlightening me to controls() made things much easier.

Cheers

daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top