If then Statements

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone please help me

I have a query with the following fields
Min Weight, Actual Weight, Vol. Weight

I need to workout what the Excess Weight is depending on which is
greaterbetween Actual Weight and Vol. Weight

Something like this:
If Actual Weight > Vol. Weight Then
Excess Weight = Actual Weight - Min. Weight
Else
Excess Weight = Vol. Weight - Min. Weight
End If.

How do i do this in the query?
 
At the top of a blank column in the query design grid, try the IIf function:

ExcessWeight: IIf([Actual Weight] > [Vol. Weight],[Actual Weight] - [Min.
Weight],[Vol. Weight] - [Min. Weight])

Base your form or report on the query, and use ExcessWeight as the Control
Source of a text box.
 
Thank you so much Bruce, your help is much appreciated

BruceM said:
At the top of a blank column in the query design grid, try the IIf function:

ExcessWeight: IIf([Actual Weight] > [Vol. Weight],[Actual Weight] - [Min.
Weight],[Vol. Weight] - [Min. Weight])

Base your form or report on the query, and use ExcessWeight as the Control
Source of a text box.

jasonn said:
Can someone please help me

I have a query with the following fields
Min Weight, Actual Weight, Vol. Weight

I need to workout what the Excess Weight is depending on which is
greaterbetween Actual Weight and Vol. Weight

Something like this:
If Actual Weight > Vol. Weight Then
Excess Weight = Actual Weight - Min. Weight
Else
Excess Weight = Vol. Weight - Min. Weight
End If.

How do i do this in the query?
 
You're welcome. Glad it helped.

jasonn said:
Thank you so much Bruce, your help is much appreciated

BruceM said:
At the top of a blank column in the query design grid, try the IIf
function:

ExcessWeight: IIf([Actual Weight] > [Vol. Weight],[Actual Weight] -
[Min.
Weight],[Vol. Weight] - [Min. Weight])

Base your form or report on the query, and use ExcessWeight as the
Control
Source of a text box.

jasonn said:
Can someone please help me

I have a query with the following fields
Min Weight, Actual Weight, Vol. Weight

I need to workout what the Excess Weight is depending on which is
greaterbetween Actual Weight and Vol. Weight

Something like this:
If Actual Weight > Vol. Weight Then
Excess Weight = Actual Weight - Min. Weight
Else
Excess Weight = Vol. Weight - Min. Weight
End If.

How do i do this in the query?
 
Back
Top