Access 2000 AfterUpdate with a Iff

  • Thread starter Thread starter Céline Brien
  • Start date Start date
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 :
 
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.
 
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.
 
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.
 
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.
 
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
 

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

Back
Top