IIf expression prob

C

Connie

i have a combo box field called type of employed whereby the user can select
either
-Company
- Self Employed(external)
- LSBU employed (Internal)

I have a course codes field, whereby i want to only allow a user to input
data into this field if they are LSBU employed(internal).
I have tried creating an Iif expression which i put in the control source of
my course codes text box

=IIf([Type of employment]="Company" Or "Self employed (External)","Not
Applicable","Please Press Browse Course")

which states that if the type of employment field is company or self
employed, it will insert 'Not Applicable'. If LSBU employed is selected from
the type of employment field, then it will insert the string "Please Press
Browse Course"

I would normally just lock the field in the properties section of that text
box, but i dont know how to do this if it is dependant on over values in the
form. Any methods?

Thanks
 
D

Dirk Goldgar

Connie said:
i have a combo box field called type of employed whereby the user can
select either
-Company
- Self Employed(external)
- LSBU employed (Internal)

I have a course codes field, whereby i want to only allow a user to
input data into this field if they are LSBU employed(internal).
I have tried creating an Iif expression which i put in the control
source of my course codes text box

=IIf([Type of employment]="Company" Or "Self employed (External)","Not
Applicable","Please Press Browse Course")

which states that if the type of employment field is company or self
employed, it will insert 'Not Applicable'. If LSBU employed is
selected from the type of employment field, then it will insert the
string "Please Press Browse Course"

I would normally just lock the field in the properties section of
that text box, but i dont know how to do this if it is dependant on
over values in the form. Any methods?

Thanks

This should work for the IIf() expression:

=IIf([Type of employment]
In ("Company", "Self employed (External)"),
"Not Applicable","Please Press Browse Course")

I had to break it onto multiple lines for the newsreader, but it would
really be one line.

But you should be aware that binding your text box to an expression like
this will make it uneditable. Was it your intention that the user
should enter something in this text box if [Type of employment] is "LSBU
employed (Internal)", and that otherwise the text box should be
disabled? If so, you shouldn't bind the text box to an expression. You
might use code in the form's Current event and in the AfterUpdate event
of [Type of employment] to set the text box's Enabled property.
Something like:

'----- start of example code -----
Private Sub EnableDisableCourseCodes()

Me!CourseCodes.Enabled = _
(Me![Type of employment] = "LSBU employed (Internal)")

End Sub


Private Sub Form_Current()

EnableDisableCourseCodes

End Sub


Private Sub Type_of_employment_AfterUpdate()

EnableDisableCourseCodes

End Sub
'----- end of example code -----

I don't know if that's exactly what you're after or not, but it rather
sounded like you want something like that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top