Queries :: Return Most Recently Created Records?
Mar 3, 2015
query to return the most recently created records in a composite key field, and only the most recent ones.
there is a screenshot of the composite key field attached
I want to get te records with the highest InvoiceID, there can be multiple records with the same InvoiceID and I want to get all of them.
Using the screenshot as an example I need to query to return the last two records as they both have the Same, highest InvoiceID.
View Replies
ADVERTISEMENT
Jun 17, 2005
I want to populate a combo box on a form with the last 10 recently viewed records from a recordset.
I have got the last 10 most recently viewed items (records) in an array
MRUL_Buffer (1 to 10) As String
I can't figure out how to get the values in the array into a combo box on the same form.
Any ideas....
Cheers
View 3 Replies
View Related
Jan 31, 2006
Hi All,
I am wandering if it possible to check programatically whether a query returns a NULL result?
I am writing a program(VB) that involves an IFF statement where if there are records in the query it does a specific calculation & if there are no records returned in the query it does something else. Is this possible to achieve?
Thanks in advance:D
Cheers,
Karv
View 2 Replies
View Related
Apr 10, 2013
My issue surrounds retrieving the last (based on most recent date) set of records based on the most recent date. I have query, containing 2 tables as the sources for the query results. Currently, the query yields:
Field A Field B Field C
123456 AAAA 1/8/13
123456 BBBBI 1/8/13
123456 CCCC 1/8/13
123456 DDDD 1/8/13
123456 EEEEEE 3/10/13
123456 FFFFFF 3/10/13
123456 GGGG 3/10/13
123456 HHHH 3/28/13
123456 IIII 3/28/13
123456 JJJJ 3/28/13
The desired results would be to return all records with the last/max date, so yield:
123456 HHHH 3/28/13
123456 IIII 3/28/13
123456 JJJJ 3/28/13
I have tried the max & last functions, yet no success.
View 1 Replies
View Related
Feb 3, 2014
I'm trying to create a query to show me records for a given year. The issue I'm having is that each record has (4) dates fields and each record can contain null values.Is it possible to do this in a query with data like the example below?
Field 1 ID (1), Field 2 Date (12/22/2012), Field 3 Date (2/06/2013), Field 3 Date (Null), Field 4 Date (Null)
In this example I would want 2013 data but would need to be able to search any year. I could also have dates in all (4) fields
View 3 Replies
View Related
Apr 4, 2015
I've got a database of club members with names, addresses, contact info etc.
I need to send letters by post to those members that I don't have email addresses for. How to create a query to return a list of people whom I don't have email addresses for.
I know how to mail merge the info with the letter I've written in word, how to group people who's email address cell is empty.
View 1 Replies
View Related
Feb 14, 2014
I understand that a query can accept wildcards in the search criteria but this is different.
I have a form on which a user selects a [product] part number in an unbound combo e.g. "12345-V111".
I then need a subform on the form to list records where the relevant field matches the left most part of this part number but is not necessarily complete. e.g. records with "12345-V1" would be returned, records with "12345-V2" wouldn't. The number of characters recorded in this field will vary, but if the characters that are entered match, then the record should be listed.
In other words, the record entries themselves need to be treated like wildcard entries.
View 7 Replies
View Related
May 2, 2013
Any way to build something into a sub-query that says 'if no records are found, return '0' or some other string'?
Otherwise is there a way to make a master query ignore sub-queries if they return no records?
Allow me to explain in more detail: I have a series of sub-queries, most of these take the sum of several fields from a number of different tables, and I have a main query which combines all of these, to be used as the basis of a summary report.
These queries aren't a problem, but I have a few other essential queries which take the modal (most common....) entry for fields which aren't numerical. So I can't use the sum function.
Now, if all the sub-queries are working then so does the main query, however if one of them fails to find a result, then none of them show up in the main query. I don't know why.
The issue is that depending on the date range selected, some of the tables targeted by the sub-queries don't have any records at all, so when they are run they return nothing. The sum queries can handle this since they just return 0, but those searching for modal records just find nothing (not 0's and not null fields, just blank across all rows).
Here's an example of my sql statement for the modal queries.
Code:
SELECT TOP 1 Trends.Trend AS ModeTboxTalk, "1" AS [Key]
FROM Trends INNER JOIN [Toolbox Talks] ON Trends.TrendID = [Toolbox Talks].TrendID
GROUP BY Trends.Trend, [Toolbox Talks].TrendID, [Toolbox Talks].TalkDate
HAVING ((([Toolbox Talks].TalkDate)<=[Forms]![WeeklyReportSelect]![WeekBox] And ([Toolbox Talks].TalkDate)>[Forms]![WeeklyReportSelect]![WeekBox]-7) AND (([Toolbox Talks].SiteID)=[Forms]![WeeklyReportSelect]![SiteBox]))
ORDER BY Count([Toolbox Talks].TrendID) DESC;
- FYI the weekly select form is where users select the week and site they want to report against. So it would be really peachy if I could tell the above to say something like 'no trend this week' if indeed there were no records.
View 6 Replies
View Related
Nov 1, 2014
I am trying to write an access SQL query that returns all records shared between table1 and table2 LESS THAN 3 TIMES.
application has 4 tables: Patients, AnnualPhysical, Doctors, and PatientPhysicalDoctors.
each patient has an annual physical (once a year), and chooses one doctor per annual physical.
each doctor can only perform three or less annual physicals per year.
It is a small application with less than 1000 records per table.
the query will allow the patient to choose an annual physical doctor once a year from available doctors.
Patients is one-to-many to AnnualPhysical;
AnnualPhysical is one-to-many to PatientPhysicalDoctors;
Doctors is one-to-many to PatientPhysicalDoctors.
query for all records NOT shared between Doctors and PatientPhysicalDoctors is:
SELECT *
FROM Doctors
WHERE NOT EXISTS( SELECT * FROM PatientPhysicalDoctors
WHERE Doctors.DoctorID = PatientPhysicalDoctors.DoctorIDFK );
View 3 Replies
View Related
Apr 8, 2013
I am trying to create a query that returns records whether a field has data or not...
There are three fields in question, SSN, DOB (this is a date field), POB (this is a foreign key representing a state in the query shows the actual state). Now unless the criterion is different then I just need the answer for one I can reproduce.
I would like to do this in the criteria box in the query.
The query pulls from one table, some of the employees in this table have the three fields populated some don't. I would like the query to return all employees...
View 2 Replies
View Related
Jul 23, 2013
I am trying to create a query pulling from several tables. I will use the example below to illustrate what I'd like to do.
I have a field called 'Acc_Num', one called 'Stat_Code', and a third called 'Cat_Code'.
Each 'Acc_Num' can have multiple records because there are multiple Stat_Code and Cat_Code values.
What I want to do is isolate just the Acc_Num records where Stat_Code = 1 and Cat_Code equals A1.
I also want to isolate the Acc_num records where the Stat_code = 1 and where Cat_code does not exist.
View 7 Replies
View Related
Sep 26, 2014
I have an existing query, created using the query wizard which works just fine - however, I would like to modify it to return only instances where there are 3 or more records appearing.
Essentially, its an employee history report for a particular action done by those employees, which returns all records between two dates as specified by the user. What I would like to do is only show those employees who have had more than three instances of this action in the given date period.
I am thinking along the lines of DCount? but how it would be phrased in the query?
View 14 Replies
View Related
Jan 17, 2014
I have a table with duplicate records (which is ok) and I want to return distinct data for each client.
It works fine when there is only two fields returned however, when I add a third field to the query it no longer returns only the Distinct records - I am getting Duplicates returned.
I.E
SELECT DISTINCT tblClient.ClientNo, tblClient.Name
FROM tblClient
Works fine with only the Distinct records for each client returned
However
SELECT DISTINCT tblClient.ClientNo, tblClient.Name, tblClient.Address, tblClient.OrderValue
FROM tblClient
Now returns Duplicates!
Is there a limit to the number of fields to be returned using DISTINCT or what else could be the problem? Should I be doing this some other way?
View 5 Replies
View Related
Apr 24, 2013
I have a table which includes a start date field and completion date field for housebuilding.
I am trying to extract all records that have either a started date or a completed date between 2 dates supplied by the user. I have tried to use Between on both fields but that doesn't return results between the fields.
It workd if I just do it on EITHER the start date field OR the completion date field so that implies to me that I need to break it into 2 queries, one returning start date recrods and the other returning completion date records but then I would need to have somthing that removes records that appear in both the start date and the completion date results.
View 7 Replies
View Related
Mar 4, 2015
I am looking for a query that will return records from a table that have related records in another table. Opposite to the Unmatched Query Wizard.I have two tables: tblSupplier and tblSupplierProducts.The two tables are related by the field "SupplierId".I need the query to only return Suppliers that have Products.
View 3 Replies
View Related
Aug 24, 2013
I'm in a form that creates the new company in the companies table. Then I want to leave a note in the notes table using the newly created company_id. Of course that id does not yet exist. What's a good way to accomplish this?
Code:
Private Sub b_EnterSave_Click()
Dim stDocName As String
stDocName = "company_quick_enter_form"
Dim CompanyIdStr As Integer
CompanyIdStr = Forms.company_quick_enter_form.Form.company_id
[Code] .....
View 4 Replies
View Related
Jun 10, 2014
I have a piece of code that is creating new records when the form loads using recordsets.
I need a subform to show only the newly created records
View 14 Replies
View Related
Jul 24, 2015
I have a button that duplicates records 'X' amount of times based on a value in a text box.
I need a message box to advise the user that they have created record number from - to
Eg
User creates 5 records - first record created has a auto number of 3200
I need the message box to say 'you have just created records 3200 - 3204
Is this possible?
Here is the current code on the duplicate button courtesy of Uncle Gizmo
Private Sub AddRecord_Click()
On Error GoTo AddRecord_Click_Err
Dim x As Integer
For x = 1 To (Me.txtAmount.Value - 1)
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
[Code] ....
View 2 Replies
View Related
Apr 23, 2013
I'm looking to move an excel sheet to access because the row counts are too much.The main thing it does is compare the supplied data against a list I hold in the sheet.There are not duplicate records, however..Some data is a direct lookup for a full match, but much of it is a count to see how many records contain a certain string.
I have 500 keywords which have a countif function in using wildcards.I need to create a query/report which will return a list of records from the original list which contains each keyword featured and how many times it features.I was going to do it in PHPmysql but the time it took to parse a million records for every keyword made it pointless.
eg:
keywords:
look
billy
magic
list:
"have a look and see"
"spanish dave"
"who is billy brag"
"looky looky I go hooky"
"who's the man from argentina"
"could it be magic now"
my spreadsheet would return a 1 next to ""billy" and "magic" and would put a 2 next to "look".
the sheet has the keyword in each row and next to the column:
=COUNTIF(list,CONCATENATE("*@",B13))
where "list" is the external data.
View 3 Replies
View Related
Aug 29, 2013
Very suddenly today, when I'd done seemingly nothing, all of the records from my form that I'd built from a blank form disappeared, with the exception of the first record. When I try to just close everything down, nothing changes. When I put in a new record to the form, however, it's saved in the table. But when I save and close, the form goes back to only having the first record! This is very annoying, for easily perceivable reasons. I even tried creating the form from scratch, to see if it's some residual SQL update code acting funny, and nothing changed! It seems to work if I select a table and just create a form, though. It doesn't even work when it's a splitform and whatnot.
View 1 Replies
View Related
Jul 1, 2005
I've read quite a few posts and noticed that quite a few people have said that forms should be created from queries. Is this personal preference or a must.
Like I said on a previous post I am going on a one day Access soon, so maybe I should stop reading and playing until I have completed that, but my mind is running away with what I want to do.
View 14 Replies
View Related
Jul 24, 2005
Hi,
I was wondering how difficult it would be to do the following:
1. A user opens up a form.
2. The user uses a combo box to select his/her name.
3. There is a date combo box on the form and by default, it is set to today's date. So when the user selects his/her name, the records for today are displayed. Changing the date will show only the records for the date shown.
4. The user will have the ability to add and delete records specific to the criteria chosen in the text boxes. Adding new records will only add records for the date chosen in the combo box. E.g. if he/she adds a record for today, it will only be seen when today's date is selected.
Will a subform have to be used for something like this? Or could it be done with one form using filters?
Any thoughts and/or approaches on this would be greatly appreciated.
TIA.
View 3 Replies
View Related
Jan 13, 2008
Okay I had an idea and I thought I might get ffedback as I am relatively new to this. I went through a period a couple of years ago when I used access alot and was becoming familiar with VBA etc but I havent touched it in 2 years so Im pretty rusty.
I am running a study and need to have to create a database that:
a. collects data about participants
b. Has a number of questionnaires (5), each of which can be filled out by participants.
THe main table has a number of fields that collects info about the participants the most important of which will be the ParticipantID - an automatically generated number which is my primary key.
In table 2/form 2 I will host questionnaire one. This will be linked to Table 1/Form 1 (Particpant Information) by this tables primary key - also the Participant ID. The relationship will be 1:1. Each participant can only have one Participant ID and will only need to fill out questionnaire one once.
Is it possible that when I add a new participant to the Participant Information table/form I also automatically create a record in Table 2/Form 2 (Questionnaire 1), as well as Table 3/Form3 (Questionnaire 2) and so on so that they have the same ParticipantID...?
I was reading a similar query somewhere else and they said to use the Form_AfterInsert Event command? Is this right (see here http://www.pcreview.co.uk/forums/thread-1687644.php)?
I feel a bit stupid but I am willing to learn and try new things Once I get started I think I will be okay. If you could steer me in the right direction it would be much appreciated.
View 12 Replies
View Related
Jun 23, 2014
I have created a database in microsoft access 2010 to show invoices for different customers in different countries. In doing so, I created using a two subforms in a main form. I have used the "country name" to link the subforms to the main form. When I enter new records into the subforms for a specific country, I realized that a duplicate record of an old record are being created in the subforms. What can I do to prevent this from happening? I tried to change the query link between the main form and subform to "invoice number" but the same problem has occurred.
I am novice to microsoft access 2010 ...
View 3 Replies
View Related
Aug 19, 2015
I have a table that has entries recorded with date and time in one field, and I want to have a query that returns all records of a specified date or date range, regardless of the time in the field.
I have tried
Code:
Between [StartDate:] And [EndDate:]
And
Code:
Between [StartDate:] & "00:00" And [EndDate:] & "23:59"
Neither of which work ....
View 13 Replies
View Related
Sep 26, 2013
Here is the SQL from my Query
SELECT PreStatus.Operator, PreStatus.Mode, Sum(PreStatus.CountOfMode) AS SumOfCountOfMode, IIf([SumOfCountOfMode]>=3,"YES","NO") AS [Current], PreStatus.Rate, PreStatus.Last, PreStatus.First, PreStatus.DET
FROM PreStatus
GROUP BY PreStatus.Operator, PreStatus.Mode, IIf([SumOfCountOfMode]>=3,"YES","NO"), PreStatus.Rate, PreStatus.Last, PreStatus.First, PreStatus.DET
HAVING (((PreStatus.Rate) Like "*" & [Forms]![Status]![Rate] & "*") AND ((PreStatus.Last) Like "*" & [Forms]![Status]![Last] & "*") AND ((PreStatus.First) Like "*" & [Forms]![Status]![First] & "*") AND ((PreStatus.DET) Like "*" & [Forms]![Status]![DET] & "*"))
ORDER BY PreStatus.Operator;
When I run Query a dialog box request for SumOfCountOfMode appears. Is there anyway I can turn this MsgBox off?This Database is used for the user to find out if their personel are current in said data. The user will be running this query through a Form and will get their results via a report if they put anything in this MsgBox it could possibly skew the data they are looking for.
View 3 Replies
View Related