IN

BB

Registered User.
Local time
Today, 04:42
Joined
Aug 31, 2001
Messages
30
Can I use IN in an if statement? If so, how?? How would be the best way to do the following?

If Me!VehicleNumber.Column(5) IN
("820", "822", "824") And
[EndMileage] - [BeginMileage] < 1000
Then
Form!fsubPerMileCharge.Form![Quantity] =
1000
Else
Form!fsubPerMileCharge.Form!
[Quantity] =
[EndMileage] - [BeginMileage]
End If

Thanks (new to Access)
 
I think you may want to consider keeping the allowed values in another table. Then, you can run a query against that table with your originating field.

oldgnome
 
Use a case statement. Here is a copy of the Access help for "Select Case"

Select Case Statement Example
This example uses the Select Case statement to evaluate the value of a variable. The second Case clause contains the value of the variable being evaluated, and therefore only the statement associated with it is executed.

Dim Number
Number = 8 ' Initialize variable.
Select Case Number ' Evaluate Number.
Case 1 To 5 ' Number between 1 and 5, inclusive.
Debug.Print "Between 1 and 5"
' The following is the only Case clause that evaluates to True.
Case 6, 7, 8 ' Number between 6 and 8.
Debug.Print "Between 6 and 8"
Case 9 To 10 ' Number is 9 or 10.
Debug.Print "Greater than 8"
Case Else ' Other values.
Debug.Print "Not between 1 and 10"
End Select

p.
 

Users who are viewing this thread

Back
Top Bottom