cwb
Posts: 5
|
| Posted: 06/26/2006, 10:33 PM |
|
I want to dynamically reference form fields to set their visibility and associated labels based on a database lookup. I have tried every combination that I can think of - but with no joy. The db side is no problem.
Basic logic is get recordset based on 'type' of object in the forms BeforeShow event then loop over the results and set the fields as required (field name, visibility, label name, label value). Basically I want to control the form output via the database...
I'm hoping that this is real easy and as a 'newbe' I've missed something very basic
|
 |
 |
peterr
Posts: 5971
|
| Posted: 06/26/2006, 10:52 PM |
|
Maybe this will help: http://forums.codecharge.com/posts.php?post_id=46849
Although I'm not sure what do you mean by setting field name or label name - those are static control identifiers.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
cwb
Posts: 5
|
| Posted: 06/27/2006, 1:26 PM |
|
Peter,
The reference article is close but not quite what I wanted. It allows me to cycle through the controls but I still can't work out how to specify an particular control explicitly - for example:
Dim c, item
Set c = EventContoller.Controls
Now open connection to database and return recordset - then loop through record rows and for each refer to a specific field by its fieldName - i.e
Set item = c.item.<fieldName> {this is the part that I can't get the
syntax right}
item.visible = false
etc
Regards,
Craig
|
 |
 |
peterr
Posts: 5971
|
| Posted: 06/27/2006, 1:40 PM |
|
Try: FormControls.GetItemByName("abc").Visible = True
or if looping through record rows containing field names in "field_name" column: FormControls.GetItemByName(fields_rs("field_name")).Visible = True
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
cwb
Posts: 5
|
| Posted: 06/27/2006, 1:51 PM |
|
Peter,
Brillant - works exactly as required.
Many thanks,
Craig
|
 |
 |
|