Limiting Records Retrieved To 10... With A Catch.
Jul 12, 2007
Hello all,
I am a buyer and I'm attempting to create a query in Access 2003 that will list all of my vendors (20 in total) and their top 10 selling sku's. Here are the fields I am using:
Buyer_Code
Supplier_Number
name
Sku_Global
OEM_Number
Part_Description_English
Status
C_Last12_SLS_QTY
I have created one Query including all of the above fields as well as the following field, "XP1: GetTen([Supplier_Number])"
In this query I have set "Supplier_Number" to sort ascending and "C_Last12_SLS_QTY" to sort descending.
I then created a module, written as follows:
Option Compare Database
Option Explicit
Public wSUPPLIER_NUMBER As String
Public wNum As Integer
Function GetTen(SUPPLIER_NUMBER) As Long
If wSUPPLIER_NUMBER = SUPPLIER_NUMBER Then
wNum = wNum + 1
Else
wNum = 1
End If
If wNum > 10 Then
GetTen = 0
Else
GetTen = wNum
End If
wSUPPLIER_NUMBER = SUPPLIER_NUMBER
End Function
I then created a second query with all of the above fields, and the criteria for the XP1 field as ">0"
As far as I can tell, this should bring me back a list with the first 10 rows for each of my Supplier numbers... unfortunately it is for some and for others it's bringing back more than 10 rows. The other problem is that it seems to be picking random rows to bring back, and not just the first 10 (which because in query1 I set the C_LAST12_SLS_QTY field to sort descending, should be my top 10 selling sku's).
Does anyone have any idea as to what I've done wrong? I'm pretty new with Access so I may be missing something pretty simple.
Any help would be greatly appreciated.
Antonio
View Replies
ADVERTISEMENT
Nov 17, 2005
Ladies / Gents !
I am writing a database for my work environment to enter sample numbers in a predefine batch. My Form contains information to identify batch ID. Attach to this form is a subform which I would like to limit the number of records to 24.
exsample: form : as unlimited records
subform: only limited to 24 records within the master form.
Now, everytime i create a new record in the master form , I should be allowed to enter only 24 records in the associated subform.
Does anyone have an idea on how to accomplish this !! Your help would be greatly appreciated.
Thank You
View 1 Replies
View Related
Feb 11, 2008
Hello,
i have tried to find an answer but can't seem to find any posts that apply.
I need to limit the records returned in a query to 3. Well, that is fine, i have set it to do the top 3, and it is working well, I am looking at the top percentages received in a number of criteria. However we have just discovered a situation where someone has 7 all with 100%, so all 7 records are being returned. I can see why, i just don't want them to be!
The report based on the query requires only three records, in this case we don't care which 3, seeing as they are all equally good, in fact randomness is a boon.
Any ideas out there - i 'm stumped!
Anna
View 2 Replies
View Related
Apr 25, 2005
Hey! I'm doing Computing AS level and the coursework is to create a system for "Terry's Turkey". This is basically my first introduction to Access, and our teacher is little to no use!
After alot of work working out things in access and reading alot of books, other than creating the switchboard, theres only a few things left to do!
The first is to limit the amount of "turkeys" that can be ordered. I have 2 tables that this envolves... Order and Customers, they have a one to many relationship (each customer may place one or more orders, each order must be placed by one and only one customer). They are linked by Customer ID. I need to set two limits, I guess by a validation rule of some kind. The first is that each Customer can place no more than 5 orders. The second is that their can be no more than 40 orders in total. A slight complication to this is that a customer can "cancel" an order, in this case its marked as cancelled (theres a yes/no field called Active to determine this), and ideally, these wouldnt be included in the counts.
So far I have the following as a query, though I have no idea how to put this into a validation rule
SELECT Count(Orders.OrderID) AS Var1
FROM Orders;
I guessed that to expand this to not including inactive orders something like
SELECT Count(Orders.OrderID) AS Var1
FROM Orders
WHERE active="yes";
Any help at all would be most appreciated! I have spent many hours pondering over this is and looking at as many access sources that I can! I think this is my last resort :(
View 3 Replies
View Related
Apr 24, 2008
Hello again my forum o' saviours, Current filter: WHERE (Assignments.[AcademicYear]) Like ([Please Enter Academic Year])AcademicYear is a field in the Assignments table (duh). In this same query, I have a couple fields (equations and if/thens built on the assignments table) that will need to be used as further filters. I thought something like WHERE ((Assignments.[AcademicYear]) Like ([Please Enter Academic Year]) )& (len([groupwinterbox])+len([groupspringbox])+len([groupfallbox]) > 3) would work, but I keep getting pop-ups asking what the values of the three query-based calculations are. Where did this noob screw up?
View 9 Replies
View Related
Sep 9, 2014
I'm trying to create an Access database for my college so that our call centre can allocate students to a specific interview time/date. The problem I'm having is that each interview slot must only have a maximum of 10 students at a time.
I'm creating tables for the student details, address and for each interview slot available.
I'm using Access 2010.
How I can limit the number of records in a table to 10 so that when that interview slot is full it informs the user?
View 14 Replies
View Related
Dec 31, 2006
Hello All,
I’m having a problem getting the correct value from a form. I have a table name CITY.
Table: CITY
Field(s): [City_ID] [City Name]
1Boca Raton
2West Palm Beach
3Sunrise
4Palm Bay
My form uses the city table as a drop down look-up field. In the form it show’s up correctly by showing the City Name only.
The problem is that I have a command button that looks up the city in the form as part of an address lookup for Mapquest, but the value it retrieves is the numeric City_ID and not the City Name. How can I fix it to see the correct column?
View 3 Replies
View Related
Oct 29, 2007
Well boys and girls, its about that time in the week where I have once again come up with a brilliant application for my little Access project, but have no idea how to make it happen.
I will start with a little background info... In the course of the parts recoveries we have different reasons for recovering parts, different people (locations) that request them, and different priorities for recoveries. For example, when a new model comes out, we will recover 100% of the parts for investigation by the factory... however, we may want to take a look at failed water pumps first. In this case, our recovery, until it is complete, will have higher priority than the 100%, otherwise we would not receive any parts.
This is because of the way our warranty system works... It assignes a three digit number to each part number of a recovery (between 1-999). The lower the number, the higher the priority.
So if I am setting up a 100% recovery, I would want to put it in the, say, 200's. This would leave room for an overlapping recovery to be inserted in the 100's where it would divert a certain number of parts away from the normal recovery stream. Then, once a user-defined date or quantity of parts has been reached, the corresponding number goes dead, and any of those part numbers are reunited with the original recovery stream.
Sticking to the example above, typically 100% recoveries would go for say... 2-3 years, where as an in-house recovery might be for 20 parts... Another difference is that the longer term recoveries are managed by the end date, where shorter term recoveries are by number of parts recieved.
What I want to do is be able to auto assign these numbers based on criteria derived from user-inputted data... (i.e. destination, start/end date, recovery type, etc.). Then, when the recovery is complete, whether based on date or quantity recieved, to delete the information associated with the 3 digit number, block its use for 45 days, and then be able to reuse the number for a new recovery.
Whew.
Thanks to anyone who can be bothered to read past the first paragraph, let alone offer any advice.
View 14 Replies
View Related
Nov 6, 2012
I'm trying to save a report to my Desktop as a pdf - adding a date {that I am retrieving from a query} as part of the pdf file name.
I get a
Run-time error '2501' - The OutputTo action was cancelled.
(See screenshot).
Here's the code I'm using. So far - all I've tried to do is run the function from the Visual Basic Editor.
Function SaveReport()
Dim strSQL As String
Dim strPath As String
Dim strFilename As String
'Get the ReportDate.
[Code] .....
View 4 Replies
View Related
Oct 25, 2005
Hi!
When I run a querry I have a parametr querry like this:
Between[FirstDate] and [LastDate]
I want to "catch" the FirstDate and LastDate from the parameter querry and place them in the head of the Report based on the same querry.
How do I do this????
View 1 Replies
View Related
Feb 21, 2006
Hi!
I have a db in Access 2003.
I have a form named frmStat with FirstDate and LastDate and five options
I want to use the values in a querry.
I can catch the Datevalue with [Forms]![frmStat]![FirstDate] and so on but how do I do to catch the value from the options button?
Jack
View 5 Replies
View Related
Jan 6, 2006
I have a db with two tables linked by a Set_ID field. One table characterizes set information (date, time, location etc) and the other table has records for groups of fish caught in the set. The fish_table has (amongt others) a field for species (text), clip-status (yes/no), coded wire tag status (yes/no), and 'count' (number). The count field is necessary to allow input of groups of fish en-masse, or individually, depending on the amount of accessory information obtained.
Obviously, some sets catch no fish and so no record is entered into the fish table for those sets.
When I design a query, I want to produce a table that sums up the count field for each set, and produces subtotals for each species (and for the 4 variations of the clip/tag status fields).
My efforts so far are only partially succesful in that I can produce the correct subtotals, but only for sets where something was caught. Sets with no corresponding fish_table record are ignored instead of treated as zeroes.
Is it necessary to manually enter a 'zero' count for each species of interest for each set that we do? (Massively time consuming) Or is there some other way to query the db that forces the query to equate no fish record with a zero value?
Any thoughts? I've searched the forum, and googled, but haven't come across anything I could recognise as analogous to my dilema.
View 8 Replies
View Related
Jul 21, 2006
Hey guys,
Anyone know how to go about catching the "Index or primary key cannot contain a Null value." message box and perhaps showing a custom message instead?
Thanks in advance,
Bob
View 2 Replies
View Related
Jun 15, 2004
I have come across this problem several times. I have sub reports on a report and calculations are done using the data in the sub report. In many instances the subreport is empty. The calculated fields read #error. (otherwise the report runs well and records with data calculate fine) I would like to hide these errors and associated labels when the subreport is empty. Everything I have tried either does nothing (error still appears in text box - but runs ok otherwise) or I get a runtime error since it is trying to access "nothing" in the sub report.
How can I catch and therefore react on this empty sub report. (or subform too)
Thanks
Lisa
View 13 Replies
View Related
Oct 21, 2005
I'm trying to limit the amount a user can enter into a employee discount field in a table. I would like to set up a validation rule in the table to limit the discount to no greater than $0.20 or 20 cents. Anyone have any recomendations? Thanks..
View 1 Replies
View Related
Feb 14, 2008
Hello, I need help. I have two tables.
horse_entries
ent_HorseName (PK)
ent_entries
horse_information
inf_HorseName (PK)
inf_Ground
inf_Notes
It is a many-to-many relationship. When I open a table and enter a record there is a small + sign that allows me to open up the rows from the other table to enter directly into it. Can this be turned off? Also I can enter more than one record through this way. I only want one entry in inf_Ground, inf_Notes and inf_Entries for each HorseName. How would I do this? As you can tell I am completely new to Access and trying to learn. Thanks :)
View 2 Replies
View Related
Nov 8, 2005
Im doing a database booking system and i need to limit the amount of people to 160 per night. At the moment i have a query that sums up the bookings per date but i dont know how to then limit this column to 160.
View 2 Replies
View Related
Jan 31, 2006
Hello All,
I have a table “subdivisions”
With a daughter table “lot numbers”
I need to limit lot numbers to no duplicates in the LotNumber field, within a subdivision, without limiting it to no duplicates in the table.
Any clues?
LotNumber is a text field.
LotNumberID is autonumber, primary key
Preferably this would be accomplished in a query.
View 3 Replies
View Related
Aug 15, 2006
I have this table
AircratfID
Flight
Time
I have a aircraft logbook with 4 entries for page
I tried to build a query that shows
"Time until this page"
"flight time"
"flight time"
"flight time"
"flight time"
"Time to copy to next page"
Anyone? Thanks
View 3 Replies
View Related
Oct 12, 2005
hi,
we have this database that's used by differerent departments and one of the fields on the form has a combo box for status (pending / completed etc). when this is set to 'Complete' we would like to make sure that it can't be changed again, is this possible?
there is only one table used in this database and updates to other fields are still required so it is only this one combo box that need to be blocked from change once in the completed stage...
Thanks in advance
View 3 Replies
View Related
Mar 24, 2006
Hi,
Just a quick question, is it possible to have a combo box in a continuous subform that automatically limits its rows based on the selections made in the other child records/combos (for the same parent record)?
Cheers,
Bobadopolis
View 10 Replies
View Related
Apr 22, 2015
I have a subform in datasheet view on a main form. The subform contains a drop down field with multiple values. I am wondering if it is possible to limit the use of one of those values by account. Basically there are 5 values (contact info updated, initial DM Contact Made, sent email/left voicemail, opportunity create, Follow up call with DM) and I only want user to be able to select the value Opportunity created once per account. The others he can select as many times as he wants.
I attached a screen shot of what the form/subform looks like.
View 14 Replies
View Related
Sep 22, 2005
Hi there
This is my problem
1) I have just spilt my data base into the front end and back end. I did this not using the wiszard. What i would like to do is to limt total acess to my databank. I want guest to be able to view my data and those who are allowed to can edit the data. How do i do this exactly
2) I want to be able to watch closely and see who is doing what, i would like to record, in a table, those who edit the data and those who enter data. i would like to keep track of whats going on in my data bank. So to seen when the data was newly added and what data to my data bank and to see who and when the changes have been made.
____
new
if there is a simple way to add the password system i am all ears
Thanks in advance.
g.
View 2 Replies
View Related
Mar 21, 2006
Need some ideas on how to detect if Time Now is beteen preset values.
It is in connection with a Machine Monitor system being I am probably going to be asked to develop.
Problem is night shift. They work normally 20:45 to 06:45 following morning
I will be accumulating elapsed minutes of shift and working minutes by running an On Timer event updating both values by 1 each minute providing certain criteria are met.
One of the criteria will be that machine is supposed to be working.
So I was planning to set a flag indicating Working Yes or No based on the Time Now being between start and end times.
This is fine for normal day working and normal day shifts but is a problem with Night Shift.
Ideas on how to handle welcome
len B
View 8 Replies
View Related
Dec 20, 2006
Hello,
I am figuring this must be an easy question. I have combo boxes setup and working great. I just noticed that I can put my own text into the box and not be limited by just the choices in the combo box. If that makes sense.
When I try to lock the boxes then it doesnt allow me to select. I want the combo boxes to be the only selection they can make, and not be able to put their own text in.
Attached a screenshot to help clarify.
Anyone know what option I am missing?
Thanks.
View 2 Replies
View Related
Jul 8, 2005
Hi,
I'm baffled by this ...
One of the forms in my database has a subform. The subform displays data from a table which is related to the data in the main form (also powered by a table) through a key relationship. So long as the relationships are set up correctly, the correct data magically appears in the subform as you scroll through the records in the main form.
I've tried to do this a second time, except in this instance the subform is displaying data from a query, and the data is related to the data in the main form not through a direct key, but through a link table. I've set up the relationships properly as before, but this time the subform stubbornly displays all the data from the query, not just that which is related to the record in the main form.
What am I doing wrong?
View 2 Replies
View Related