Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2007, 09:18 PM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default IIF Formulas used in Update queries

I am importing data from an old database (we call it AS400) into my Access'03 database. The data corresponds to price increases shown as follows...

     CustNum,P/C,PreviousPrice,FuturePrice,EffectiveDate
     80000,123456,0.1234,0.0000,
     80000,123457,0.1234,1.1234,10/01/2007

The system does not update the future price if there will not be a price increase (as shown above)... When there is a price increase, it does not show the increment, but the updated price. I used the IIF Formula to select the correct price...

     10/01/07: IIf([tblQuotes]![Increased]<>0,[tblQuotes]![Increased],[tblQuotes]![Previous])

In a select query, I get the desired result; one field labeled with the most recent price increase. But I would like to update these numbers to a table with a field named for the date of the most recent price increase. My intention would be to eventually track my price increases over time for various products and customers. I tried to use my IIF statement in an update query where the field to update to was named 10/01/07. That's when it crapped out... the error message reads,

     "'IIF([tblQuotes]![Increased]<>0,[tblQuotes]![Increased],
     [tblQuotes]![Previous])' Is not a valid name. Make sure that
     it does not include invalid characters or punctuation and that
     it is not too long."

I only get this message if I change my query type to an update query... which is what I *think* I want to do. Of course, that's where it gets dangerous... sheep who think. Can anyone give advice on how else I can store data as ONE field to track it every time I have a price increase? i've already searched for Update queries and IIF Formulas. I've seen lots of stuff out there but nothing directly related to my issue. Any help would be appreciated.
 
Old October 9th, 2007, 06:46 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure if the date is a valid field name.

I would suggest restructuring the table to two tables in order to keep a history of price increases. I wouldn't rely on adding a new field named for the date each time you want to update prices. Is that what you are trying to do?

In any event, there has to be a field named 10/07/07 in the updated table to receive the values from your equation on the update. Are you able to select the target field when making the update query?

mmcdonal
 
Old October 15th, 2007, 12:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

This is an odd table structure. If you want to keep a history of prices, I would just have one price field and one date field to show what the price was at that date. Say the price was first set on 9/1/2007, so instead of:

CustNum, P/C, PreviousPrice, FuturePrice, EffectiveDate
80000,123456,0.1234,0.0000,
80000,123457,0.1234,1.1234,10/01/2007

I would have

CustNum, P/C, Price, EffectiveDate
80000, 123456, 0.1234, 9/1/2007
80000, 123457, 1.1234, 10/01/2007

In that way, you can always track price vs. date and get a history. To get any price increase difference, just subtract the two prices for any two given dates.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old April 6th, 2018, 11:39 AM
Registered User
 
Join Date: Apr 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help for this Formula

I use this formula in excel to get P.Tax from gross. "M6" is gross. =IF(AND(M6>3501,M6<10001),0,IF(AND(M6>10001,M6<150 01),110,IF(AND(M6>15001,M6<25001),130,IF(AND(M6>25 001,M6<40001),150,IF(M6>40001,200,0)))))

Now can anyone help me how i use this type of formula in access?
 
Old April 10th, 2018, 08:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

If you're talking about what to put into an Access query, then you can express this as:

PTax: IIF(M6>40001,200,IIF(M6>25001,150,IIF(M6>15001,130 ,IIF(M6>10001,110,0))))
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old April 12th, 2018, 09:06 PM
Registered User
 
Join Date: Apr 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I also have similar questions, have not found a solution





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formulas Juan0214 Access 4 July 2nd, 2008 02:04 PM
Need help with time formulas pfreire727 Excel VBA 1 February 12th, 2006 07:41 PM
Inputbox and Formulas bahachin Excel VBA 3 February 17th, 2005 01:39 AM
update/insert work in queries but not on form jonicholson Access VBA 3 January 18th, 2005 06:05 PM
Update queries socoolbrewster Access 4 March 4th, 2004 06:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.