If Then Question

AndyShuter

Registered User.
Local time
Today, 18:47
Joined
Mar 3, 2003
Messages
151
I can use If....Then....Else Ok I think, but I'd love to know how you put multiple criteria in a command

For Example - This command sets the value of a field if a car is less than 365 days old

If Me!VehicleDaysOld < 365 Then
Rate = Forms!frmMaintenance!Text584

End If

....But What I'd really like to do is keep the cammand going to check other perameters for example

If Me!VehicleDaysOld < 365 Then
Rate = Forms!frmMaintenance!Text584
If Me!VehicleDaysOld is between 365 and 730 Then
Rate = Forms!frmMaintenance!Text586

etc
etc

Please Help

Andy



End If
 
Andy,

Check the help files for the "select case" statement

Or search the archives here.

Plenty of examples for what you want to achieve.

Post back if you still have trouble.

Brad.
 
Maybe this is what you're looking for:

If Me!VehicleDaysOld < 365 Then
Rate = Forms!frmMaintenance!Text584
Elseif Me!VehicleDaysOld is between 365 and 730 Then
Rate = Forms!frmMaintenance!Text586
Else
End if

The Elseif command will check for other criteria other than what you originally looked for. THe other thing you could try using is a Select Case statement.

Select Case Me!VehicleDaysOld
Case Is < 365
Rate = Forms!frmMaintenance!Text584
Case Else
End Select

Play with these and let me know if that helps,

Vassago
 
Beat me to it Brad. Quick fingers or lack of typing code? :D
 
Struggling!

Cant seem to get the right syntaxt for the "BETWEEN" and "AND" bit!
 
Post what you have so far.

(Maybe Vass will correct it for you.)


No, I'm sure someone will be able to correct it if you post the code.



Brad
 
You can't use Between...And in that way.

Use >= bla bla bla AND <= bla bla bla
 
As it seems that each case is actually counting between years maybe a loop would be the better option with the DateDiff() function.
 

Users who are viewing this thread

Back
Top Bottom