dbTalk Databases Forums  

Re: I am desperate for a query

comp.database.ms-access comp.database.ms-access


Discuss Re: I am desperate for a query in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
parn
 
Posts: n/a

Default Re: I am desperate for a query - 06-27-2003 , 03:57 PM






Agree with first response, you best best is to create a function like
below:
************************************************** ****
Public Function CalcCharge(strService as string, strPkgType as string,
sglSTC as currency) as currency

if strService = "Express" then
select case strPkgType
case "LETTER"
CalcCharge = sglSTC-(sglSTC* .422)
case "Box"
CalcCharge = sglSTC-(sglSTC * .392)
Case "PAK"
CalcCharge = sglSTC-(sglSTC * .035)
end select
elseif strService = "Ground" then
select case strPkgType
case "Letter"
CalcCharge = ------------
case "Box"
CalcCharge = ____________
Case "Pak"
CalcCharge =____________
end select
else strService = International
Select Case strPkgType
Case.......
(go thru the 3 package types)

end select
end if

end function
*********************************
Then in your query, put in a column CalcCharge([Service Fld Name],
[package type field name],[Shipment Transportation Charge field name])




Bob wrote:

Quote:
Sorry for cross-posting but I am pretty desperate

I have an Access 2000 db. In my db is a table for shipment records.
I have 3 columns I have to deal with, Service, Package Type, and
Shipment Transportation Charge

What I need is some kind of query to get the following data

IF Service = Express AND Package Type = Letter THEN subtract 42.2%
FROM THE Shipment Transportation Charge Field

IF Service = Express AND Package Type = Box THEN subtract 39.2% FROM
THE Shipment Transportation Charge Field

IF Service = Ground AND Package Type = Box THEN subtract 3.5% FROM THE
Shipment Transportation Charge Field

I have about 21 instances of different service and package types. They
will always be constant
either Express, Ground, International. The package will always be
Letter, Box, Pak, Express Box.

Is there anyway this can be done?

Thanks
Bob


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.