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

Trouble using IN on the form

Status
Not open for further replies.

jen1701

Programmer
Dec 20, 2003
57
US
I want to use IN function to validate the EmpNo. whether it is in a list on a form. So on the employee no. field, after update event, I have the following codes:

If Forms![Entry]![Employee Number] In ("001","177","148","110","224") Then
Forms![Entry]![0 Defects].Locked = False
End

But I can not get it compiled. There is a compile error - syntax error.

Please Help! What syntax it should be!

Thank you very much in advance.

jen
 
There might be several different ways of doing such. One method I use from time to time is the select case statemet:

[tt]Select Case Forms![Entry]![Employee Number]
Case "001","177","148","110","224"
Forms![Entry]![0 Defects].Locked = False
Case Else
Forms![Entry]![0 Defects].Locked = True
End Select[/tt]

Roy-Vidar
 
Jen,

Try using a single value instead of the IN range to see if your code will work.

Or you may wish to try using a case statement to do the evaluation of the values in your list instead.

HTH,

Steve
 
Roy,
Thanks a lot for the quick reply. I will try your suggestion.

Have a nice evening

Jen
 
Hi Steve,

It does work with a single value. I will try the case statement. Thanks a lot for the reply.

Have a nice evening

Jen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top