Sort Orders In Queries

Dec 7, 2006

i've now converted a large database to run with sql as well as linked jet tables. The main issue was checking every recordset to ensure it opened properly. I also found that sql returns a few different errors code from Jet, that needed trapping differently = all OK.

Now, in some cases I had opened the backend Jet table directly in order to use seek on a particular index, so this needed changing, as this is not available with SQL

I may well be wrong but i couldn't see an easy way of traversing a recordset table in SQL/ODBC according to a particular segmented key

Instead I was able to modify my process to extract the data I wanted with a query, and I then used a recordset on the query, which is fine.

HOWEVER, to emulate the index I was using, the query is sorted on about 6 or 7 different segments, the first of which is CustomerCode. Now when I opened the query to view it, I changed the sort order by clicking on a date column (as it happens) to sort it. When I then closed and reopened the query it still opened sorted on the date column, which is not right, as the customners are now all out of sequence. When the whole dataset was re-extracted it did return to the original and correct order

THEREFORE Is there a way of forcing a query to reset itself to its original ordering sequence. I think it is not likely that any user would ever open a query directly anyway, but it would be nice to ensure the query is always processed in the intended order. Perhaps it isn't a problem at all - maybe when a query recordset is opened in code, the sort order is reset anyway, but I would appreciate some views on this.

Thanks in anticipation

View Replies


ADVERTISEMENT

Alphabetical Sort Orders.

Sep 20, 2005

Hello.

How can I preserve the user-defined sort order in a column in a table?

Every time I exit the table, and go back, my items have been alphabetically sorted. This results in my Combo Box displaying the list in alphabetical order, rather than my custom order.

Thanks ahead.

View 2 Replies View Related

Modules & VBA :: Entering Orders Into The Orders Table?

Mar 5, 2014

I have a database where I have 3 tables. first is client data, second orders data and third the products data.
What I would like, is to have a button on my form that after selecting from a combobox a product, it wil enter it in the tabel orders in the next available free record (row). I created a button and the combobox in the client form. The Products table has also the price per unit in it. It should take the whole row of data and put it in the Orders table.

Is there a way to do this? I guess it needs to be done with vba, but not sure.

View 9 Replies View Related

Queries :: Evaluate How Many Orders Were Open On Specific Day

Dec 12, 2013

Access 2010 project I am trying to develop for my workplace.

I want to be able to show a chart, a graph, of how many open orders we have had during the last month (showing per day) and during the last year (showing per months). In order to do this I am trying to create a set of queries that would provide me with such information in the form/structure;

[Date] [OpenOrdersTotal]
Yyyy-mm-dd 4
Yyyy-mm-dd 5
Yyyy-mm-dd 3
Yyyy-mm-dd 4

And after that I would create a chart I have
1. TblOrders
[OrderID] Autonum
[CaseID] Foreign primary key
[DepartmentID] Foreign primary key
[DateOrderMade] Date (yyyy-mm-dd)
[DateOrderAnswerd] date (yyyy-mm-dd)

2. TblDates
[ReportDate] Date (yyyy-mm-dd)

The evaluation in a query that runs all [ReportDate] logically would say;

Code:
Count(IIF([ReportDate] BETWEEN [DateOrderMade] AND [DATEORDERANSWERD]);1;0)

...but that wont do it.

I have attached a copy of the segment above ....

View 14 Replies View Related

Queries :: Finding Work Orders That Only Contain Certain Type Of SN

Aug 13, 2013

I am new to access but understand how to do a simple query. in this case i have 4 fields in my query. I only want to return work orders where the only SN's for that work order begin with 600 or NEX. when i use the like button it gives me all those work orders, however it doesn't exclude the work orders with other types of SN's. is there a formula i can use that says return work orders that only contain this type of SN?

View 14 Replies View Related

Queries :: Dates In A Query - Show Orders By Month For Last 12 Months

Apr 22, 2013

I want to create a simple query from a list of orders dating back over 12 months.

The fields I have is Ord_Date, Qty

I need to show the orders by month for the last 12 months.

The problem I am getting is that the orders for the month of April (as we are in April now) contain orders from 1st - 22nd April 2013 and orders from 23rd - 30th April 2012, therefore confusing the figures.

I would just like orders grouped by month with a total qty dating back 12 months, but without any old orders for the current month.

View 6 Replies View Related

Queries :: Rolling 12 Month Query - Keeping Track Of Orders Placed For Given Part Number By Month

May 5, 2014

I am trying to create a database that will keep track of the orders placed for a given part number by month. Currently, my table houses the part number, and the ordered amount for the past three years by month (there are thirty-five columns for every part). My column headings are ORDER_MAY_2013, etc. I would like to set a query up that will look at the column headings and pull the amounts ordered for each part for the past twelve months. In other words, I have three years of data in my table. In my query, I just want one year. However, I don't want to have to rewrite the query every month so that it will pick up the new data. Is there a way to accomplish this?

Is there a better way to build this database? I thought about just have four columns in my table - PART_NUMBER, ORDER_MONTH, ORDER_YEAR, ORDER_AMOUNT. The only problem there, is that every part (there are about 450 parts) would have to be listed 35+ times. That seemed too redundant to me, so I built the table this way. However, now I am having trouble querying against it.

View 2 Replies View Related

Queries :: Using IIF For Sort Criteria

Jul 23, 2013

I am creating a query to select and sort events whose payments are overdue, prioritizing those that are most overdue at the top. The catch is that the due dates for payment varies based on several conditions and criteria.

Here's my end goal of the sort order (it's not in SQL, I'm just describing it):

1st step- If [Program_Code]="BD" Or "GT" Or "SG" Or "SC" Or "PR", then the sort criteria is [Date_of_Event] < Date()

2nd step- If [Program_Code]="WE" Or "KD", then the sort criteria is [Date_of_Invoice] < Date()

3rd step- If [Program_Code]="ZM" And [Cost_Category]="Full Price" Or "Discount", then the sort criteria is [Invoice_Date]+30 Days is < Date()

4th step- If [Program_Code]="BD" Or "PR" And [Deposit_Paid] Is Null, then the sort criteria is [Invoice_Date] < Date()

I'm not sure how to go about this but I have a feeling it involves an iif statement in the SQL and/or breaking it into smaller queries that are then consolidated into a "master" query.

View 14 Replies View Related

Queries :: Specific Sort Order

Sep 13, 2013

I have a query that is returning running conditions for a machine over multiple shifts. the table is set up like this

Code:
date shift parameter condition
09/13/13 1 front 500
09/13/13 1 middle 450
09/13/13 1 back 475
09/13/13 2 front 510
09/13/13 2 middle 460
09/13/13 2 back 490

this is just a small example. there are about 24 different parameters reported on in a shift..I want the query to sort by date ascending, shift ascending, and then by parameter in a specific custom that i define. I want it ordered "front, middle, back" for each shift. Again this is just an example, there would be 24 parameters I want in a specific order. Then do I need to define the sort order again for the report based on this query?

View 3 Replies View Related

Queries :: Sort Row Headings For Crosstab Query

Feb 26, 2015

I have a created a crosstab query which gives me the results I need, but I want to sort the row headings differently. These are not numbers, but machine sizes which range from 4 Metre to 20 Metre. Currently, the crosstab gives me:

10 Metre
12 Metre
14 Metre
17 Metre
20 Metre
3 Metre
4 Metre
5 Metre etc

But I need to show it as:

3 Metre
4 Metre
5 Metre
10 Metre
12 Metre
14 Metre
17 Metre etc.

The field is short text data type and data comes from an ODBC linked table to SQL server table, and I am using Access 2013.

View 4 Replies View Related

Queries :: Sort Months Logically And Not Alphabetically

Mar 3, 2015

I have a report (based on a query)which informs staff of students who withdrew from our school, and the month and date they withdrew (sorted ascending). I am grouping by month and it looks like the attachment I've included.

It works well enough, but what I would really like is for the month column (Month([withdrawldate]) to show January for 1, February for 2, and so on, but I find that when I do that, the months sort alphabetically, and not logically.

View 14 Replies View Related

Queries :: Sort By Year Is Sorting By Month

Sep 16, 2013

I've created a query based on 2 other queries.

I then filter the results of the third query based on 2 dates.

This worked great for 2013.

As a test I started making some records for 2014 and I've now found that my third query is not filtering the dates properly.

The filtering is happening based on date fields that contain only month and year eg: "09-2013".

My problem is that when I try to filter for records in 2014 it brings up results for 2013 as well.

If for example I had a record in August 2013, September 2013 and August 2014.

The sort would be:

08-2013
08-2014
09-2013

NOT:

08-2013
09-2013
08-2014

How do I make the sort apply to month then year to get the correct results returned?

View 6 Replies View Related

Queries :: How To Sort Mails Separated By A Comma

Feb 11, 2015

I have a field email in the table 2015. I woud create a query that sort my mails separated by a comma. E.G.

123@456.com
456@789.fr
...
Sorted =

123@456.com,456@789.fr, ...

View 2 Replies View Related

Queries :: Sort By User Input Order

Apr 30, 2013

I have a simple form with a text box, I enter a series of part numbers separated by newlines, and then I use the following code to query for each of the separate part numbers:

Code:
Dim strSql As String
Dim part_nums() As String
Dim num As Variant
Dim multivar As Boolean
multivar = False

[Code] ,......

This all works perfectly, but what I need to do is have the query return the records in the same order I entered the part numbers. They are automatically returned in alphabetical order by item_no, and when I enter 15+ part numbers it becomes slightly difficult to search through them all on the form to find the one I am looking for. It would be a lot easier if they were output in the same order that I type them in. Is there any way to make this happen?

View 1 Replies View Related

Queries :: How To Sort Records By Grand Total Descending

Aug 9, 2013

I've recently been building a database on Access to replace the rather clunky and slow one we currently use here (built in Excel).Generally, I've been making it up as I go along which has worked quite well for me so far. However, I've encountered pivot tables. Normally, it shouldn't be a problem; the tables themselves are easy enough to understand. However, I've found that the tables aren't nearly as flexible as I would have liked. At least, not in a way directly apparent to myself.

(After trying, and failing, to include links to Imgur with details on my issue, I have included a .zip file with both images I was going to show)Generally, in Excel, the table works everything out for us, then we sort by largest to smallest and work out the totals for the last 7 days and the last 7-14 days (the week before last). After that, the last formula works out a percentage (loss or gain). [excel.png]

In the access table, though, I can't find a way to make this happen. There's no readily apparent button to add a new calculation field. I've tried using the create calculated total button, but that seems intent on making a separate total for each day on the table, which I don't want. [access.png]

Also, I can't figure out how to sort the records by grand total descending. I would have thought right clicking the grand total and clicking sort descending would have done it, but apparently that would be far too easy. I feel that it's prudent to mention that I'm not all that experienced with Access. I completed MOS and ECDL courses when I was in primary school, but it's been a really long time since that and all of the Office applications have changed rather dramatically.

View 1 Replies View Related

Queries :: Sort Order In Query Based On ID (Autonumber)

Sep 10, 2013

This is something I occasionally see in Access and has been bugging me for quite a while.

As an example, when I have a table (all text fields except for the ID field which is an Autonumber with a unique index - ie just what Access creates when you import data) and I try to make a new table from a query by indexing the Autonumber field in descending order (ie to reverse the order of the table), it doesn't work properly.

So if I have:

SELECT [mytable].* INTO [mytable sorted] FROM [mytable] ORDER BY [mytable].[ID] DESC;

When I preview the data (ie run the select query to have a look at it), it looks fine.

When I change the query to a 'Make Table' and I then I check the table it makes, the order changes part-way down the list, so looking at the ID field it runs from number 2669 down to 2087 correctly, then it goes from 1960 to 1956, then 1803 to 1799, then 1751 to 1747, etc etc etc. After a while it seems to correct itself again, and orders normally down to #1

I'm using Access 2002.

View 5 Replies View Related

Queries :: Dynamic Cross Tab Query - Column Sort By Corresponding ID

Apr 23, 2015

I have a dynamic cross tab query - thus the column headings will change each time it is run.

At present the column headings are displayed in alphabetical order - how can I change this so they are based on a different order - eg by the descriptions corresponding ID

View 3 Replies View Related

Queries :: Cannot Change Sort Order On Float Field

Apr 22, 2013

I have a query with a float/delta column which is the expression:

Code:
Float: [Date1] - [Date2]

When I try to change the order by in the column filter drop-down i get a data type mismatch in criteria expression error.

View 1 Replies View Related

Queries :: Create Query To Sort Table In Particular Order

Feb 28, 2014

I have a table with multi columns with unsorted data.

I want to run query to sort data in multiple columns.

How can i do it?

View 1 Replies View Related

Queries :: How To Sort A Union Query SQL Statement For A Report

Oct 1, 2013

I have a Union Query (that works perfectly fine) with the following code:

Code:
SELECT * FROM sbqryUseBattery
UNION
SELECT * FROM sbqryUseBeltsDeck;
UNION
SELECT * FROM sbqryUseBeltsHydro;
UNION
SELECT * FROM sbqryUseBeltsPTO;
UNION
SELECT * FROM sbqryUseFiltersAir
UNION
SELECT * FROM sbqryUseFiltersFuel
UNION SELECT * FROM sbqryUseFiltersOil;

I am using this information on a Report.

The problem is that the Report shows the data in random order. Is there a way to filter either the Union Query or the Report?

View 14 Replies View Related

Queries :: Possible To Sort A Table Drop Down Box By Date Within A Query?

Oct 3, 2013

Is it possible to sort a natural table drop down by date from within a query? What im doing:

1. making a query that has certain results displayed
2. within the query you can select one of the field boxes and it has a list of all the items in that table.
3. is it possible to sort this natural table listing from within the query. I have attached a screenshot. Same thing happens with the client ID listing from within the query. Want to know if it is possible or not to sort those. I cant see how.

View 1 Replies View Related

Queries :: 3 Tables - Set Up Tabular Form As Sort Of Checklist

Dec 31, 2013

So I'm trying to set up a Tabular form as sort of a checklist

Example Step 1, Step 2, step3, etc etc etc

I have the form setup with 4 tabs or 4 seperate forms within 1 form (works nice) now I trying to set up my query to open the form and I have 3 tables linked to the form. see bitmap

When I add the 3rd table to the query my forms opens to a blank screen no pages and no fields ....

View 7 Replies View Related

Queries :: Cannot Sort Query - Enter Parameter Value Error

Sep 16, 2014

I cannot sort below query in descending order by absolute value. If I do not use sort, all works fine but as soon as I try to sort by absolute value I get message to 'Enter Parameter Value'. I tried to replace Abs([Variance (W2 - W1)]) with filed name AbsoluteValue and still the same result ;(

Code:

SELECT [Query Union].[Stock Code] AS SKU, [Query Union].[Pallet No] AS [Pallet No], [Query Union].[Batch No#] AS Batch, IIf(IsNull([qW1 SOH].[Physical stock]),0,CDbl([qW1 SOH].[Physical stock])) AS [W1 Qty], IIf(IsNull([W2 SOH].[Good Stock]),0,CDbl([W2 SOH].[Good Stock])) AS [W2 Qty], [W2 Qty]-[W1 Qty] AS [Variance (W2 - W1)], Abs([Variance (W2 - W1)]) AS AbsoluteValue

[code]....

View 4 Replies View Related

Queries :: Sort Crosstab Query Columns And Generate Report

Jul 28, 2015

This is a query, report and vba question. I'm using Ms Access 2007.

TABLE 1: projectname, activityname, totalhoursworked, employeename
TABLE 2: employeename, employeelevel
TABLE 3: employeelevel, rate

I created a select query to join the info that I need.

SELECT QUERY 1: projectname, activityname, employeename, totalhoursworked, rate, cost (calculated field (totalhoursworked*rate))

I have 2 crosstab queries.

CROSSTAB QRY 1: ROW (projectname, activityname) COLUMN (employeename) VALUE (totalhoursworked (summed))
CROSSTAB QRY 2: ROW (projectname, activityname) COLUMN (employeename) VALUE (cost (summed))

I then created a 2nd select query with inner joins to join both crosstab queries on similar fields (activity & projectname).

SELECT QUERY 2: projectname, activityname, employeename (totalhoursworked as value), employeename (calculatedcost as value)

It gives me this:

However, I want it like this:

Those employeename... refers to more employees being added after a period of time. Hence I want to know if I could use vba to generate a report every time a button is pressed on a form? I know how to link the form to the query.

View 8 Replies View Related

Queries :: Sort By Percentage Match To Multiple Field Search

Mar 19, 2014

We're trying to create a database to read quotes from a system based on changes made to components.

We have the database set up to store the quotes happily. We're pleased with the input forms and data capture however we are struggling with a query to get useful data from the database.

I have a main quote data table listing all the required fields such as costs and supplier data for the quotes, a table storing components that may be changed as part of a quote and a table listing alterations that could be made to these components. Each quote could have a number of changes made to a number of components. All these changes are stored in a changes made table which lists the quoteID, ComponentID being changed and The AlterationID of the alteration being made.

I want to be able to input a varied amount of changes via a form and be shown a list of all quotes where at least one change matches. I've managed to get this far using a lot of OR statements however the complexity is introduced as we need to sort these by an extra column produced by the query displaying the percentage the changes made in the quote match the search input.

If a quote appears matches my changes and there are no other changes on the quote - (100%)

If a quote matches all changes I have input but I input 5 changes and the quote has 6 - (5/6 - 83%)

If I input 1 change and a quote matches but has 8 changes on the quote - (1/8 12.5%)

View 2 Replies View Related

Queries :: Count And Sort Criteria - Returning On Blank Values

Nov 18, 2013

I have a list of employees and sort criteria. for example

empID....Criteria
1234......T
1234......F
1234......T
1234......F
1235......F
1236......T
1236......F
1236......F
1236......F
1236......T
1236......T
1237......F

The output I am looking for is a count of the number of times T appears by an employee, BUT is there is no record it would return 0

E.G.
empID......Count
1234...........2
1235...........0
1236...........3
1237...........0

I can get it to return:
empID......Count
1234...........2
1236...........3

using Count and the criteria Where Criteria="T" but not returning zeros.

View 2 Replies View Related







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