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

Getting Field Names from Form 1

Status
Not open for further replies.

LWB

Technical User
Feb 4, 2003
95
US
I always seem to have questions!

I want to get the names of all the fields displayed on a form and put into an array. I tried:

MyForm.enumFieldNames(arFieldNames)

but that just gets the field names of one of the tables in the Data Model.

Since I now have a bunch of calculated fields on the form that are not in a table, is there an easy way to get the names of those fields into an array?

Lynn
 
Lynn,

I think the only way to do it is with enumUIObjectNames(), here is some ugly code to do it.

method pushButton(var eventInfo Event)
var
f Form
ar, ar2 Array[] String
endVar

f.attach()
f.enumUIObjectNames("fieldNames")
tc.open("fieldNames")
scan tc for tc.objectClass = "Field":
tc.objectName.breakapart(ar2,".")
ar.addLast(ar2[2])
endscan
ar.view()
tc.close()
endMethod

Perrin
 
Perrin,

Thanks. I ran into a problem, however. All my fields are inside boxes (the ones I will color based on the field content) and your code picks up the box name and not the field name. I'm not sure why it would identify a box as a having a class type of "field".

Lynn
 
Lynn,

If you open the table "fieldNames" I think you will see what's going on.

enumUIObjectNames() returns each object along with all of it's containers. I used breakapart to seperate the containers.

#Page2.#Field78
#Page2.#Box5.#Field78

Better code to catch the field name would have been
ar.addLast(ar2[ar2.size()])

Perrin
 
Perrin,

That did it. Thanks!

If it wasn't for you and Lance, I'd never get half this stuff figured out.

Lynn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top