Access 2000 AfterUpdate with a Iff

C

Céline Brien

Hi everybody,
In a form, when I select the departement of the employee, if the number of
the departement is a certain number, I would like to check a box in another
field.
Something like that :
 
C

Céline Brien

Hi everybody,
I found the answer.
I used a Case statement.
Have a good day !
Céline
-----------------------------------
Select Case NoDepartement
Case 154
Me.Good = -1
Case 155
Me.Good = -1
...

Else
Me.Good = 0
End Select


Exact coding may be slightly different. This is air code from the top of my
head.
 
K

Klatuu

Your first solution is better, but just needs the syntax cleaned up.

If Me.NoDepartement >= 154 and <= 170 Then
Me.Good = Vrai
End If



Céline Brien said:
Hi everybody,
I found the answer.
I used a Case statement.
Have a good day !
Céline
-----------------------------------
Select Case NoDepartement
Case 154
Me.Good = -1
Case 155
Me.Good = -1
...

Else
Me.Good = 0
End Select


Exact coding may be slightly different. This is air code from the top of my
head.
 
D

Douglas J. Steele

Uh uh.

That needs to be:

If Me.NoDepartement >= 154 And Me.NoDepartement <= 170 Then
Me.Good = Vrai
End If

although I don't see why you changed it from her original

If Me.NoDepartement > 153 And Me.NoDepartement < 171 Then
Me.Good = Vrai
End If

Alternative, Céline, your Case statement could have been simplified to

Select Case NoDepartement
Case 154 To 170
Me.Good = -1
Else
Me.Good = 0
End Select


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Klatuu said:
Your first solution is better, but just needs the syntax cleaned up.
 
K

Klatuu

doh!
Sorry about that. Don't know what I was thinking.
As to the change, it is just a habit I have. Although both are logically
the same, using the >= and <= explicitly shows the inclusive range. IMHO,
better self documenting.
 
C

Céline Brien

Hi everybody,
Hi Klatuu,
Hi Douglas,
Thank you so much for your answer.
If Me.NoDepartement >= 154 And Me.NoDepartement <= 170 Then
Me.Good = Vrai
End If
I was close ! But with computer, close is not enough...
Have a good day !
Céline

Klatuu said:
Your first solution is better, but just needs the syntax cleaned up.

If Me.NoDepartement >= 154 and <= 170 Then
Me.Good = Vrai
End If
 
Top