Maximum Value

uk

Board Regular
Joined
Nov 4, 2003
Messages
101
I have a table called Sales, in it I have fields: Customer number, Customer Name, Item purchased, Vaule of Sale, Date of Sale.

I want to create a query where I can Enter a customer Number and it will give me the most recent purchase info. I am guessing ussing the 'max' function is the way to do it but no luck so far!

Any Ideas?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try this:
In the query, sort Descending on your ID field. This will give last orders first.
In the top of the design area, there is a Top Values dropdown. You can enter a number like 1 or 5, or 15%, to filter the last n values. Now filter for the client in question. You should end up with the last n orders for that client.

Denis
 
Upvote 0
SydneyGeek

thanks I had tried that but, it isnt as robost as what I need, I need a fixed query I can drop the customer name into and the latest sales data will come out without having to sort the table etc.
 
Upvote 0
OK, you'll need a form for searching. Create a blank form. Call it frmSearch. On it, place a Combo linked to ClientID, but showing Client Name for ease of use. Call this combo, cmbClient.

In the query, in Design view, find the ClientID field. In the Criteria row, type this: [Forms]![frmSearch]![cmbClient]
close and save the query. The query could be called qryLastOrders.

Back to the search form. In Design view, with the Control Wizard on, drag a Command button onto the form. In the list of possible actions, find Open (ir is it Run?) a query. Pick your query (qryLastOrders) from the list of options. OK. Save.

Open the form in Datasheet view. Pick a client from the list, click the button, voila.

Denis
 
Upvote 0
sounds cool, what If I want to see the latest sales info for all my customers at once?
 
Upvote 0
sounds cool, what If I want to see the latest sales info for all my customers at once?
Then you'll need a different query. Build a query with Client Name, OrderID, and other details that you might need. Click the Sigma button at the top of Design view to get the Totals row. Most of the fields will have Group By. Change the option for OrderID to Max. Save as qryLatestOrders.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,590
Messages
6,160,666
Members
451,662
Latest member
reelspike

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top