473,803 Members | 3,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access assistance, if you can. Query related.

56 New Member
Hi,

I wondered if you could help me with an issue I'm having. Currently I have a rebate calculation that is running off two tables:

1) A list of suppliers and the rebate %ages relevant to them
2) A ongoing list of invoice details, including a month/year period and an invoice total

At the moment, I can happily run the rebate calculation for the current month. What I would like to do is begin to track changes in supplier rebate rates over time. This means applying a month/year period for the date which the rebate is applicable against each line entered on the rebate table.

The theory is that when I run my query, it goes in, finds the correct rebate rate to apply from a specifed period and then calculates based on those rates. This means I can track changes, but also run the calc historically if necessary (which is the end purpose of my calc).

The problem I'm having is, no matter what I enter in my query, it seems determined to give results for each and every line that exists in the supplier rebate table, regardless of the date that is against that line.

For example, I can have data that is like:

Supplier A - 2% - 2007-03
Supplier A - 3% - 2007-08
Supplier A - 5% - 2008-01

on the rebate table. If I run a calc with a run date of 2007-10, I want it to go and pull off all the October 2007 rebates, and then use the rebate rate of 3% against it. At the moment it gives me results for 2%, 3% and 5%, a record for each.

If this doesn't make sense, I could expand further!

My existing query is this if you find it useful:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT Rebates_Supplier.ClientNumber, Rebates_Supplier.Name AS Supp, Rebates_Supplier.Group, Sum([Rebates_CBS Transaction Data]![Base Amount]*-1) AS [Gross Amount], Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*Rebates_Supplier!CBSRebateAmt/100) AS CBS, Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*Rebates_Supplier!PfHRebateAmt/100) AS PfH, Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*Rebates_Supplier!TotalRebate/100) AS Total, [Rebates_CBS Transaction Data].[Rebate Date], Rebates_Supplier.Category, Rebates_Supplier.Status, Rebates_Supplier.CBSRebateAmt, Rebates_Supplier.PfHRebateAmt, Rebates_Supplier.Frequency
  3.  
  4. FROM Rebates_Supplier INNER JOIN [Rebates_CBS Transaction Data] ON Rebates_Supplier.Name = [Rebates_CBS Transaction Data].Name
  5.  
  6. GROUP BY Rebates_Supplier.ClientNumber, Rebates_Supplier.Name, Rebates_Supplier.Group, [Rebates_CBS Transaction Data].[Rebate Date], Rebates_Supplier.Category, Rebates_Supplier.Status, Rebates_Supplier.CBSRebateAmt, Rebates_Supplier.PfHRebateAmt, Rebates_Supplier.Frequency, Rebates_Supplier.Category
  7.  
  8. HAVING (((Rebates_Supplier.ClientNumber)>0) AND (([Rebates_CBS Transaction Data].[Rebate Date])="2007-08") AND ((Rebates_Supplier.Category)="C") AND ((Rebates_Supplier.Status)="Active") AND ((Rebates_Supplier.Frequency)="Monthly"));
  9.  
  10.  
Feb 4 '08
15 2024
Rabbit
12,516 Recognized Expert Moderator MVP
There's a few problems.
  1. Your rebate date field isn't of date data type.
  2. You didn't use a subquery to select the correct record.
  3. In the SQL statement a few posts prior, you never accounted for the supplier in the subquery.
Feb 13 '08 #11
Widge
56 New Member
I've been given this as a solution! It works!

Expand|Select|Wrap|Line Numbers
  1. SELECT A.Name AS Supp, Sum([Rebates_CBS Transaction Data]![Base Amount]*-1) AS [Gross Invoice Amount], Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*A!CBSRebateAmt/100) AS CBSRebate, Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*A!PfHRebateAmt/100) AS PfHRebate, Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*A!TotalRebate/100) AS Total, [Rebates_CBS Transaction Data].[Rebate Date], A.CBSRebateAmt, A.PfHRebateAmt, A.DateAppliedFrom
  2. FROM Rebates_Supplier AS A INNER JOIN [Rebates_CBS Transaction Data] ON A.Name=[Rebates_CBS Transaction Data].Name
  3. WHERE (((A.DateAppliedFrom)=(SELECT MAX(DateAppliedFrom)   FROM Rebates_Supplier AS B   WHERE A.Name = B.Name AND B.DateAppliedFrom <= #8-1-2007#)))
  4. GROUP BY A.Name, [Rebates_CBS Transaction Data].[Rebate Date], A.CBSRebateAmt, A.PfHRebateAmt, A.DateAppliedFrom
  5. HAVING ((([Rebates_CBS Transaction Data].[Rebate Date])="2007-08"));
Feb 14 '08 #12
Rabbit
12,516 Recognized Expert Moderator MVP
That's good, but it's very specific. It only works for August 2007. If that's all you need then that's fine.
Feb 14 '08 #13
Scott Price
1,384 Recognized Expert Top Contributor
I've been given this as a solution! It works!

Expand|Select|Wrap|Line Numbers
  1. SELECT A.Name AS Supp, Sum([Rebates_CBS Transaction Data]![Base Amount]*-1) AS [Gross Invoice Amount], Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*A!CBSRebateAmt/100) AS CBSRebate, Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*A!PfHRebateAmt/100) AS PfHRebate, Sum(([Rebates_CBS Transaction Data]![Base Amount]*-1)*A!TotalRebate/100) AS Total, [Rebates_CBS Transaction Data].[Rebate Date], A.CBSRebateAmt, A.PfHRebateAmt, A.DateAppliedFrom
  2. FROM Rebates_Supplier AS A INNER JOIN [Rebates_CBS Transaction Data] ON A.Name=[Rebates_CBS Transaction Data].Name
  3. WHERE (((A.DateAppliedFrom)=(SELECT MAX(DateAppliedFrom)   FROM Rebates_Supplier AS B   WHERE A.Name = B.Name AND B.DateAppliedFrom <= #8-1-2007#)))
  4. GROUP BY A.Name, [Rebates_CBS Transaction Data].[Rebate Date], A.CBSRebateAmt, A.PfHRebateAmt, A.DateAppliedFrom
  5. HAVING ((([Rebates_CBS Transaction Data].[Rebate Date])="2007-08"));
Hello Widge,

As a full member now with the number of posts that you currently have, we expect that you begin to use the [code] tags without being prompted! They are simple to use. Simply select the code text and click on the # button on the top of the message window. You can manually edit the first tag to reflect the language of the code: [code=vb] or [code=sql] for Visual Basic or SQL respectively.

Thanks!

Regards,
Scott MODERATOR
Feb 14 '08 #14
Widge
56 New Member
Hello Widge,

As a full member now with the number of posts that you currently have, we expect that you begin to use the [code] tags without being prompted! They are simple to use. Simply select the code text and click on the # button on the top of the message window. You can manually edit the first tag to reflect the language of the code: [code=vb] or [code=sql] for Visual Basic or SQL respectively.

Thanks!

Regards,
Scott MODERATOR
Ooops, sorry Scott!
_______________ _
Mar 7 '08 #15
Widge
56 New Member
That's good, but it's very specific. It only works for August 2007. If that's all you need then that's fine.
Yeah, that was a specific example, I subbed out that for a variable in my final piece of code.
Mar 7 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

3
7559
by: deko | last post by:
From what I understand, an Inner Join narrow the rows selected to the table with the least results... and an Outer Join does the opposite... SELECT qryTxToQ1.Q1Total, qryTxToQ2.Q2Total, qryTxToQ3.Q3Total, qryTxToQ4.Q4Total FROM qryTxToQ4 OUTER JOIN (qryTxToQ3 OUTER JOIN (qryTxToQ1 OUTER JOIN qryTxToQ2 ON qryTxToQ1.TxAcct_ID = qryTxToQ2.TxAcct_ID) ON qryTxToQ3.TxAcct_ID = qryTxToQ2.TxAcct_ID) ON qryTxToQ4.TxAcct_ID = qryTxToQ3.TxAcct_ID;
2
14941
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data in the format that I need it in order to create the reports that we use. So far this has proven to be successful for the reports that I am doing and the data that I am pulling into it. I just have one challenge that may require a lot of work and I...
1
4180
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a couple of tables in my database using INNER JOINS and the WHERE clause to specify the required constraints. However, I also want to read two fields from a *single* record from a table called 'Locations' and then apply one of these field's values...
2
5018
by: SenseForAll | last post by:
First please note I am a novice at VBA and not even that experienced with DAO/ADO and MS-SQL. Any assistance is appreciated. That said... I have an application written in Access w/ VBA. I need to get some data out of a SQL server and into an Access table. I don't know anything about the SQL server data model or structure. I don't have access rights to link to the SQL table. What I do have is the rights and information to run a stored...
0
2024
by: Rolan | last post by:
I know what I want to do regarding the average cost for inventory, but need some assistance to sort out some of the details to finalize an inventory table and query. Essentially, the information is needed for year end reporting and not for on-going review. Below is an example that summarizes it all. tblMain/frmMain /IDTag tblPurchases/sfrmPurchases/IDPur/PurCost/UnitsPur tblSales/sfrmSales/IDSales/UnitsSold
5
2769
by: Bob Alston | last post by:
I am looking for any Microsoft Access based software that could be used for a United Way agency that provides basic needs assistance - food, clothing, financial (rent, utilities, Rx, gasoline, etc). Preferably free. Definitely with source code as we would most likely want to customize it. Are you aware of such? Bob
2
1545
by: Jan Szymczuk | last post by:
Thanks again guys, for your recent assistance. Now as you were so kind to assist the first time (the solution was so simple and elegant) I was wondering if you could assist with another couple of problems I am faced with. Problem 1 I have a memo field called NOTES in my database and I have constructed various queries so the user can search this NOTES memo field for any freetext held within it. As this memo field has large chunks of text...
52
9997
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server 2005, and, since he already has licenses for Office Pro 2002, he wants to upgrade to that. I've been saying that we need to upgrade to Access 2003, not 2002, even if Office is kept at 2002. We are also looking to do a fair amount of...
3
2260
by: gaurav92K | last post by:
sir i am working in a company . there are many pc. i want to use remote assistance. i configure all group policy which are related remote assistance.and i enable service through remote in system property.every services related remote desktop & remote assistance are start . but i can not use help assistance through another system while i try help assistance in my pc then help assistance begin start. what is problem please give the best answer on...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.