Forum Home
Press F1
 
Thread ID: 19165 2002-05-10 01:25:00 Access: Case statement? Guest (0) Press F1
Post ID Timestamp Content User
48037 2002-05-10 01:25:00 I am constructing a Database for an assignment, and I need to include shipping charges, The problem is I can't work out how to set it so that if the weight is between say
100-200gms the charge is $2 if its between 201-300gms is $5 etc, I can do it in pascal but Access is completely confusing me I can't seem to even get started, so some help would be appreciated. or a good Website with Tutorials as my text doesn't seem to cover this function.
Thanks in advance
Guest (0)
48038 2002-05-10 06:07:00 How about a descending chain of IF statements? Like 'If Wt .gt. 300 then Frt=10 else if wt .gt. 200 then Frt = 5 else if Frt .gt. 100 then Frt = 2.5 else Frt= 1' (recognise the Fortran greater-than?).

This will depend on how it drops out of if .. then .. else constructs. (If Access has that construct...)
I agree that's what the case stement is for. I like Pascal too.
Guest (0)
48039 2002-05-10 08:06:00 Here's a simple example (Access 2000) using two controls on a form:

Private Sub Value0_AfterUpdate()

Select Case CInt(Me![Value0])
Case 100 To 200
Me![value1] = 2
Case 201 To 300
Me![value1] = 5
Case Else
Me![value1] = 999
End Select
End Sub
Guest (0)
48040 2002-05-10 08:37:00 Click the 'View' icon to get a 'slightly better' presentation (indent tabs have disappeared). Guest (0)
1