If and then statements - embed a list of fields? (1 Viewer)

Geordie2008

Registered User.
Local time
Today, 15:29
Joined
Mar 25, 2008
Messages
177
Hi All,

I have 2 fields which will determine which fields on a form are enabled.

1) [Employee Indicator] "Employee" or "Non employee
2) [Employee Status] "Active" or "Inactive"

If the person is an "Employee" and "Inactive" then only 1 field should be enabled called [Inactive_Status] all others should be disabled.

If the person is a "Non Employee" then I want to set the value of[Employee Status] to "Inactive" and then all fields except the following should be disabled on the form:

[Reason_for_leaving]
[Replaced]
[Replaced_by]

else if The person is an "Employee" and "Active" then all enabled except:

[Reason_for_leaving]
[Replaced]
[Replaced_by]
[Inactive_Status]

I have written some VERY messy code to try and do this, but I have ended up listing all of my form fields and then either putting enabled = true or emabled = false.

Its likely Im going to have to add in fields to the form so I would like to set them all (as appropriate within the "if" statements described above) to be enabled and then disable key fields as necessary. O where appropriate set them all to disabled and then enable key fields (if this is possible)

Is there a less messy way of doing this? Maybe by naming a list of all fields and then calling this list within the code? I just dont want code that is several pages long (I have c.40 fields)

Thanks,
Mandy
 

Geordie2008

Registered User.
Local time
Today, 15:29
Joined
Mar 25, 2008
Messages
177
Mmmm.... I think the only bit I need guidance on is:

Is it possible to set all of the text boxes and combo boxes on a form to be enabled = false at the same time? Without having to list and name them all individually

Then I can go through and enable the ones I want, when I want them :)

Thanks,
Mandy
 

chergh

blah
Local time
Today, 15:29
Joined
Jun 15, 2004
Messages
1,414
Try something like

Code:
dim i as integer

for i = 0 to me.controls.count - 1
   me.controls(i).enabled = false
next i
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom