Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 8th, 2007, 10:18 PM
Registered User
 
Join Date: Oct 2007
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old October 9th, 2007, 07:46 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old October 15th, 2007, 01:53 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #4 (permalink)  
Old April 6th, 2018, 12:39 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?
Reply With Quote
  #5 (permalink)  
Old April 10th, 2018, 09:42 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #6 (permalink)  
Old April 12th, 2018, 10:06 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formulas Juan0214 Access 4 July 2nd, 2008 03: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



All times are GMT -4. The time now is 10:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.