Queries :: Query Most Frequent Record?

Aug 4, 2013

Our local radio station has a database that records which user plays which track and when, manually entered.

I'm looking into making a query that can tell them the top 5 most played tracks this month. So basically I need a query that returns the 5 most frequent records within the current month.

View Replies


ADVERTISEMENT

Frequent Error In Referring / Linking Textbox In Subform From Text Box Within Main Form

Apr 17, 2013

Go to frmInvoice, and you'll see a Net Total box (txtNetTotal) . It's control source is linked to a textbox in the subform fsubInvoiceDetails2 called txtStocktotal. It basically just pulls up all the costs associated with that InvoiceID.

The reference mechanism is as follows: =[fsubInvoiceDetails2].[Form]![txtStockTotal].Now...sometimes this works and sometimes it doesn't! Sometimes i've had to use: =forms!fsubInvoiceDetails2!txtStockTotal.

It seems to be very temperamental at times and i'm not fully confident if this can be explained.By way of note, I use express builder normally to input these statements: I go to Forms > ALL FORMS > fsubInvoiceDetails2 > txtstocktotal.

View 2 Replies View Related

Queries :: Trying To Use Query In Record Set

Jun 13, 2013

I'm trying to use a query in a recordset and I'm getting errors. The query was created in Access using a SQL table. The query and table are in my current database. I get runtime error 3061 (expected 3 parameters) at line in red.

Public Sub UpdateLotsizes()
Dim curDatabase As Object
Dim rstQryLot As Recordset
Dim rstInvLoc As Recordset
Set curDatabase = CurrentDb
Set rstQryLot = curDatabase.OpenRecordset("QryLotsize3")

[code]....

but then I get a compiler error "user defined type not defined". Do I need another add-in?

View 11 Replies View Related

Queries :: Query From Multiples Into One Record?

Jun 18, 2013

We have a query that pulls information from four tables. What we need to do is do a query or something else to pull the data from the existing query into a table/excel file. The problem we are having is that we want just one record for each person with all of their class selections in one field. Is this doable?

View 4 Replies View Related

Queries :: Record Counter In Query

Dec 11, 2013

In my query called "test" I have the following fields: EmpID & DEPT, below is an example.

EMPLOYEEDEPTcounter1016321101101632125210163222033557031501355703120235570313033557031404

I would like to add a column to my query called "counter" and count starting with 1 each time the employee number is listed, when the employee number changes I would like the counter to start over again at 1 and continue this throughout the query.

View 13 Replies View Related

Queries :: Can't Get Query To Even ALLOW To Update Record

Jul 1, 2015

I can do this in like 5 seconds in SQL Server but I can't get the query to even ALLOW me to update records.

Table1 - Columns
Query1 - ColumnDesc

Code:
SELECT DISTINCT C.Column
FROM Columns C INNER JOIN (
SELECT Cols.Column, Count(Cols.DataType)
FROM (SELECT DISTINCT Columns.Column, Columns.DataType FROM Columns) Cols
WHERE Cols.DataType = 'char' OR Cols.DataType = 'varchar'
GROUP BY Cols.Column
HAVING Count(Cols.DataType) > 1
) C2 ON C.Column = C2.Column;

Simple, straight forward query, that grabs all the rows from table Columns where there are more than one DataType per Column [name], and either one of those datatype strings are 'char' or 'varchar'.Now I want to UPDATE table Columns to set all of the columns whose "column" value is in the above query, and set all those DataType values to 'VarChar'. Thus I run that UPDATE query, and the above query should come back empty afterwords in SQL Server I would simply write:

Code:
UPDATE Columns
SET DataType = 'varchar'
WHERE EXISTS (
SELECT 1 FROM ColumnDesc INNER JOIN Columns ON ColumnDesc.COlumn = Columns.Column
)

And this would already have been done.But Access doesn't like that syntax. using the designer it created sql like this:

Code:
UPDATE Columns INNER JOIN ColumnDesc ON Columns.Column = ColumnDesc.Column
SET Columns.DataType = 'varchar'

But that wasn't an "Updateable" query.I have to run this on several patterns and right now I'm completely screwed if I can't get this to work.

My end goal is to have:
SELECT DISTINCT Columns.Column FROM Columns
return the same # of rows as
SELECT DISTINCT Columns.Column, Columns.DataType FROM Columns

for each duplication I will have to do different algorithm, but I can't even get one update query to work so I'm currently frustrated (and ready to reaffirm my belief that Access should have been discontinued 5 versions ago).

View 1 Replies View Related

Queries - If No Data In Certain Field, Don't Query Record

May 1, 2006

Hi!


How do I write this in the criteria box?


Thanks for your help!!!!

View 3 Replies View Related

Queries :: Cancel Age Calculation Query For One Record

Mar 26, 2013

I have the following age calculation query:

Age: (Now()-[DOB])365

It works a treat! However, I do not want this to continue to calculate if the record has them as deceased - I want it to stop at their date of death.

I have a tick box that when selected indicates that this record has died, and a field where you can enter date of death.

Is there some way that via clicking this button, or by entering a date of death, I can stop the Age Query from calculating for just that relevant record, not all of them? If so, where to place the necessary VBA, etc?

View 8 Replies View Related

Queries :: Hide Duplicate Record Using Query

May 18, 2015

I have a question on hiding duplication record using query.

The fields in the query are:

full name(trainee), NRIC(trainee), gender(trainee), preferred language(trainee), company(trainee), course name(course), course date(course), competent(course), class(course), L3 survey(trainee), L4 survey(trainee), num of month(course)

When the query is being run, it will show all the people that have not done the L3 and L4 survey after 3 month. The the query will be convert into a form. However the problem is that the record will show a few same name due to one person can take more than 1 course. therefore, the data in the course table will always be different.

How can i make the record only show 1 name even though they have different course name.

I had tried putting 'yes' for unique record and unique value but it did not change the result.

current SQL query:

SELECT DISTINCT trainee.[Full Name], trainee.NRIC, trainee.Gender, trainee.[Preferred Language], trainee.Company, course.[Course Name], course.[Course Date], course.Competent, course.Class, trainee.[L3 survey], trainee.[L4 survey], DateDiff('m',[Course Date],Date()) AS [Num of Month]
FROM trainee INNER JOIN course ON trainee.NRIC = course.NRIC
WHERE (((course.Competent)="c") AND ((trainee.[L3 survey])=False) AND ((DateDiff('m',[Course Date],Date()))>=3)) OR (((trainee.[L4 survey])=False) AND ((DateDiff('m',[Course Date],Date()))>=6));

View 6 Replies View Related

Queries :: Update Query Not Working On Last Record

Jun 26, 2014

I have this update query that is triggered by an after update event on a main form. The record being updated are in a continuous subform. It works well except from the last added/modified record. If I save and close the form and then open it again it works for all records but if modify or add a record, the update query will not work for that last modified/added record.

I have tried several things such as save record, use dirty = false for the on exit event of the subform control but nothing works. Here is the procedure:

Code:
Private Sub cboPoCurrency_AfterUpdate()
On Error GoTo ErrHandler
Dim db As Database
Dim strSql As String
Dim lngID As Long
Dim dblRate As Double
Set db = CurrentDb

[Code] ....

View 14 Replies View Related

Queries :: Query That Returns All Record For Only Last Date

Apr 30, 2014

i want to write a query that display records for only last date entered in a table and i want to show all the records from last date entries in a table.

View 6 Replies View Related

Queries :: Find Previous Record In A Query?

Jun 13, 2015

How do I find the previous record in a query using the autonumber field?

View 10 Replies View Related

Queries :: Can't Delete Record In Unmatched Query

Jan 12, 2014

Access 2010

I created 3 find unmatched queries from the query wizard. The first one works great. I can delete a record in the query and it deletes the record in the main table.

The second one allows me to delete a record and gives me the pop up box that says " you are about to delete 1 record". I click yes, but when I check the table or reopen the query the same record reappears.

The third query does not even give me the option to delete.

I can create a regular select query and delete the records form 2nd and 3rd but not from the queries made from the unmatched wizard.

I am using the same fields in all 3 queries.

I do not have enforce referential integrity or the other 2 options checked in the relationship properties. (not sure if this makes a difference.)

I even tried to redo the unmatched queries but I get the same result for all 3.

I want to be able to delete the records in the other 2 queries.

View 4 Replies View Related

Queries :: Query To Pull Previous Record

Jan 20, 2014

I have a form that is used to book a new event for a client who is already in the database.Within that form I have a subform that is based on a query which displays information from that client's previous event. I did this using a solution found in the following thread: URL...It is based on pulling the second to last record that is related to the current client. It works perfectly when booking a new event that has taken place on a previous date. However, if the previous event occured on that same date (but at a previous time), it doesn't register.

I would prefer a query that would pull the record previous to the current one, instead of pulling the second to last record out of all that client's events.it would also mean that if more events are booked, then a past event is opened in a form, the sub forms in that form will display the event just prior to the current record.

View 14 Replies View Related

Queries :: Unique Record Table Query

Oct 22, 2013

I am using a software drawing program that intelligently link information from a drawing to a database and vice versa. I have many tables and queries that I have created over time that enable auto populating of tables, creation of tables and so on. All of which enable me with tabular documents for ordering purposes.

The problem I currently have is: - I want to create a table that looks at an existing table, analysis various fields for duplicate information and then adds one record to a new table. This is to enable me to create a spares list based on the entire list.

I have a full valve list with various items, some duplicates some not. I am required to produce a spares list that considers only one of each type.

View 10 Replies View Related

Queries :: Append Query One Record Several Times

Feb 13, 2014

I have a table with rooms each room have a number of gust. I want to append each room many times equal to the number of gusts.

View 1 Replies View Related

Queries :: Refer To Previous Record In A Query

Mar 29, 2015

I'm trying to refer to previous record in a query and i'm stuck as i do not know how to do it.

Here is my query:

Code:
SELECT
[Prod2Buy].[Product Code],
IIF([Missing] IS NULL,0,[Prod2Buy].[Quantity To Order]-[To Order]) AS [Rest To Order],
s.s_manu_code AS [Manufacturer Code],
s.prod_cost AS [Price Code],

[Code] ....

In fact the line: IIF([Missing] IS NULL,0,[Prod2Buy].[Quantity To Order]-[To Order]) AS [Rest To Order] should refer to previous record.

View 9 Replies View Related

Queries :: JOIN Query To Return Most Recent Record?

Aug 18, 2014

I have two tables with a one to many relationship. The tables are linked by the INDEX column.

EXAMPLE:

Code:
TABLE_1
INDEX NAME
1 Name_A
2 Name_B
3 Name_C

TABLE 2
INDEX NUM_INDEX STATUS
1 1 REJECTED
1 2 REJECTED
1 3 OPEN
2 1 CLOSED
3 1 REJECTED
3 2 OPEN

I need the NAME field from TABLE_1 and the Last STATUS field from TABLE_2 (MAX of NUM_INDEX).

Example:
Name_A, OPEN
Name_B, CLOSED
Name_C, OPEN

SQL that I have now.

Code:
SELECT A.FIN_Finding_Number, B.Max_Index
FROM TBL_Findings AS A INNER JOIN (SELECT RES_Finding_Index, Max(RES_Response_Index) As Max_Index
FROM TBL_Response GROUP BY RES_Finding_Index ) AS B ON A.FIN_Finding_Index = B.RES_Finding_Index
WHERE (((A.FIN_Finding_Index)=34));

This SQL statement will return me the Finding_Number and Max_Index. I don't need the Max_Index. I need the Status. If I put the Status in the Sub-Query and GROUP BY it, it will return both REJECTED and OPEN. I just need it to return OPEN.

View 2 Replies View Related

Queries :: Reset A Query Or Macro When Open A New Record?

Oct 15, 2013

Is there anyway to reset a query or macro when you open a new record? My database seems to be holding on to data from the previous record. The data is gained from two queries and one macro.

View 1 Replies View Related

Queries :: If 0 From Subtract In Query Then Goto To Previous Record

Oct 5, 2014

I want substract from 9/20/2014 totreg40 - reg = ovt but when reg=0 the remainder subtract from 9/19/2014 (previous record) totreg40 - reg = ovt, etc. The sum of reg = 40.

IDFECHA REGOVTTOTREG40
2309/15/2014 5.5 0 46.75
2319/16/2014 8 0 46.75
2329/17/2014 8 0 46.75
2349/18/2014 7.75 0 46.75
2979/19/2014 8 0 46.75
2359/19/2014 8 0 46.75
2339/20/2014 1.5 0 46.75

I want the result like this:

IDFECHA REG OVT TOTREG40
2309/15/2014 5.5 0 46.75
2319/16/2014 8 0 46.75
2329/17/2014 8 0 46.75
2349/18/2014 7.75 0 46.75
2979/19/2014 8 0 46.75
2359/19/2014 2.75 5.25 46.75
2339/20/2014 0 1.5 46.75

View 1 Replies View Related

Queries :: Getting Latest Record For A Particular Customer Number Using MS SQL Query

Jul 27, 2013

My table appears like this with the following columns:

Name| CUSTNo| ORderNo.| AcctDate| OrderDate| OrderDescription

I would like to write a ms-sql query to return the records of each customer number with the latest OrderDate. One more thing, if the customer has two separate order numbers on the same date(should be the latest date), the query should be able to pull up both the records.

I tried with the code below but its taking a long time to execute and finally hanging up MS ACCESS.

SELECT * FROM TableName AS a WHERE Not Exists (SELECT *
FROM TableName b WHERE b.CUSTNo = a.CUSTNo AND b.OrderDate >= a.OrderDate);

View 2 Replies View Related

Queries :: How To Print A Label For Each Record Returned By Query

Dec 27, 2013

I have a query that returns several records, typically 1 to 5. I need to print a label for each record returned by the query. Printing a label is no problem, but how do I print sequentally for each record in the query?

View 2 Replies View Related

Queries :: Correlated Query Returning Only 1 Record And Repeating

Aug 10, 2014

I have SQL query/dual sub-query in MS Access that is returning data from the left side of the query FROM correctly, but is only returning one record from the right side of the query FROM. Furthermore, it repeats the display of the one record and it repeats the entire results set with a different one record each time until all the records have been displayed. I expect that problems described as "Furthermore" will not exist by fixing the one record issue. I have tried using all the join types available in MS Access, but none change the result.

The desired output is:
Yellow Blue
11/23/2013 11/19/2013
11/19/2103 10/01/2012
10/01/2102 10/08/2010
10/08/2010 12/14/2007

The actual output is:
Yellow Blue
11/23/2013 11/19/2013
11/19/2103 11/19/2013
10/01/2102 11/19/2013
10/08/2010 11/19/2013
11/23/2013 10/01/2102
11/19/2103 10/01/2102
10/01/2102 10/01/2102
10/08/2010 10/01/2102

The same pattern is repeated 2 more times with Blue values of 10/08/2010 and then 12/14/2007.

Here is the SQL:

SELECT Long_List.Yellow,Short_List.Blue
FROM
(
SELECT DISTINCT BirthDate AS Blue
FROM (
SELECT DISTINCT BirthDate FROM citizens
UNION

[Code] ....

View 11 Replies View Related

Queries :: Detect When Query Fails To Find A Record

Oct 29, 2013

I have ASSET_TYPE, MANUFACTURER and MODEL tables.

I have a Table ASSET_COMBO that links to the above tables.

I have a form to create amend an ASSETS table. The form uses combo fields to filter the options available to the user. I.E the User Picks Manufacturer then selects from list of Asset Types provided by that Manufacturer, then selects from list of Models.

I want to create a form to allow create and amend records on the ASSET_COMBO Table.

The problem I have is that I want to ensure that there are no duplicates on ASSET_COMBO Table. I know that I can Select Multiple keys from the table with no duplicates allowed. But from what I have read this can cause problems. Is there a simple way that I can detect that a query on the ASSET_COMBO Table has returned a valid record or has not found a record.

View 3 Replies View Related

Queries :: Finding Max Record Based On Primary Key In Query

Jul 25, 2015

How to find the max value of a field in a query... How does a query display the max record based on the primary key... want to isolate the last record created, the one with the max primary key.

View 2 Replies View Related

Queries :: Select Active Record In A Table Using A Query

Nov 30, 2013

Based upon a specific date (varDate), I want to select the record that is active (who drives the lease car).

row 1 user X from 13/11/2013
row 2 user Y from 15/11/2013
row 3 user Z from 17/11/2013

I want to find the active user on a date. So on date 13/11/2013 (=varDate), user X is active, on 14/11/2013 (=varDate), user X is still active, on 15/11/2013 (=varDate), user Y is active, on 16/11/2013 (=varDate), user Y is still active and on 17/11/2013 and later, user Z is active.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved