Queries :: Function To Output Line Numbers In A Query - YTD

Apr 18, 2014

Is there a built in function which can be used to create line numbers in a query?

I've written a query to calculate year to date (YTD) points for yachts in a series of races and sorted it in descending order - so yacht 1 is coming first, yacht 2 is coming second etc. I'm looking for a way to add sequential numbering (starting at one and increasing by one for each line) into the query to represent their YTD places. Or this this something that should be left to the report which uses the query?

View Replies


ADVERTISEMENT

Modules & VBA :: Automate Line Numbers And PO Numbers

Aug 24, 2014

I have 2 fields that I would like to automate if possible

One field is called "p/o number" and another field called "line no"

These fields are part of an ordering database

Let say I have 200 items to purchase form 10 suppliers

And form example 20 items from each supplier

What I do at present is put the order number on each line item and the line number

example

p/o number line no

1 1
1 2
1 3

2 1
2 2
2 3
2 4

What I want to do is just put the first po number in the required line . Put the first line number in i.e. "1" and the macro will complete all the p/o numbers and line numbers for me as per the ones marked in red.

Example

1 1
2 2
3 3

2 1
2 2
2 3

View 5 Replies View Related

Command Line (Input, Output, Error)

Mar 16, 2007

I had looked at the Shell() function but I don't see it doing anything such as input and output.

Does anyone know the use of the VBA's command line that would send an input and receive an output to the VBA's variable?

View 2 Replies View Related

Subform Line Numbers

Nov 17, 2004

Hi! This is my first time writing in. I have been struggling with Access for the past 2 months... I am stuck with a problem. I have a variation of the Order form in the Northwind Example, with a subform called OrderDetailsExtended. The primary keys for the OrderDetails Extended subform and its corresponding table are the orderNumber (which is the link with the mail Orders form) and Item. Basically, my question is.. each time i want to add a new record, I want the Item number to automatically increment (but i am not using autonumber for this). The item field is currently disabled.

However, each time i enter a new record, the item number automatically becomes 0. And if I close the form and reopen it, the number changes to 1... Here is the VBA code i used...

Private Sub ProductCode_Enter()

Dim vItem As Variant
vItem = Nz(DMax("Item", "orderDetails", "orderNumber = ' " & Me.orderNumber & " ' "))

If Me.Item = 0 Then

If IsNull(vItem) Then

vItem = 1

Else

vItem = vItem + 1

End If

Me.Item = vItem

End If
End Sub

Please help me....

View 3 Replies View Related

Queries :: Remove GROUP BY Line And Stick Semicolon At End Of Previous Line

Jun 25, 2013

Here's the statement

Code:

sqlfinal = "SELECT Employees.ID, Employees.Name "
sqlfinal = sqlfinal & "FROM ((qryDeptVBA INNER JOIN qrySkillVBA ON qryDeptVBA.ID = qrySkillVBA.ID) "
sqlfinal = sqlfinal & "INNER JOIN Employees ON qryDeptVBA.ID = Employees.ID) "
sqlfinal = sqlfinal & "INNER JOIN qryAreaVBA ON Employees.ID = qryAreaVBA.EmpID "
sqlfinal = sqlfinal & "GROUP BY Employees.ID, Employees.Name;"

If i simply remove the GROUP BY line and stick the semicolon at the end of the previous line (.EmpID; ) it works just fine. How is adding a group by line causing an error?I tried adding another parenthes at the beginning ((( and ending the joins as EmpID); and that failed with the exact same error.

View 12 Replies View Related

Queries :: Adding Value To Query Output

Dec 12, 2013

I have a field in a query that shows amount of hours a site is covered. This field name is Coverage hours and it changes depending on the number of work days in a month. This part is working correctly but some times additional hours may be requested by the customer.

I want to add a another field to this query that will prompt me if their were any additional covered hours. Then I would have the ability to enter a value and the shown output for this field would be the value entered plus the standard coverage hours in the other field.

I'm not sure how to set up the new field.

View 10 Replies View Related

Queries :: Modifying Query Output

Feb 13, 2014

I am trying to modify the output to only show discontinued items. While the query is in datasheet view, the text is read as "YES" or "NO" under discounted items. So, I tried entering "YES" in criteria while in design view, but keep getting an error message stating, "Data type mismatch in criteria expression".

View 5 Replies View Related

Queries :: Multiple Records Appear In Output Of Query

Mar 4, 2015

i have got 2 tables i am trying query against. in table 1 i have a list of records which only appear once in the table under 1 field. in table 2 list of records which may have the same record appear under the same field numerous of times with different data in other fields on the table. i have created the reationship between both tables but i am getting multiple records appear in the output of the query where i only want the record to appear once in the output.

View 2 Replies View Related

Queries :: Get Output Of Query In A Parameter (VBA Variable)

Jul 1, 2015

How could i get output of a Query in a VBA variable ?? I'm trying as below butIi'm getting error:

Dim output As Integer
vari = DoCmd.OpenQuery("qryCompare", acViewNormal, acReadOnly)

Output of a query is a single MAX value.

View 4 Replies View Related

Tables :: Come Up With Automatic Line Numbers For Each Specific Order?

Oct 2, 2014

I am trying to come up with automatic line numbers for each specific order. So for example, I have job number 123456 that has ordered 3 items, what I would like is that item 1 has a field with a 1 in it automatically, and item 2 has a 2 in the field and so on. But the trick is that when order 123457 gets entered and has 5 items entered, I would like it to start over at 1 and go to 5. Does this make sense? Is it possible to do this in a table? Or can this happen on the form? That I assign a value to a field. I am using Access 2010, have been for a few years now, but I have lots to learn.

View 14 Replies View Related

Queries :: How To Add A Text Line To A Query Field

May 18, 2013

I have a combo box that gathers data based on a query. Is it possible to add a line of text to be displaed every time i pull down the box?

For example I have:

Data1
Data2
Data3

I would like to have:

Not In List (the added txt)
Data1
Data2
Data3

View 2 Replies View Related

Trend Line Function.

Jun 12, 2007

Hi all,

I would like to have a function in an access query showing the slope of a trendline (the linear one in excel).

Do you know how to create it?

Fuga.

View 3 Replies View Related

Queries :: Creating Query With Single Line Per Employee

Mar 28, 2013

I currently have a database that has the following tables:

t_Employees
t_Cost_Centers
t_Changes

The [t_Changes] tracks what cost centers the employee is in with a start date and end date:

Change_ID
Employee_ID
Cost_Center_ID
Start_Date
End_Date

I want to run a query that will show a single line per employee, and different columns for each of the cost centers the employee was in. If the employee was in 3 different cost centers, the query would have 4 columns (1 for the employee, 1 for the first cost center, 1 for the second cost center, 3 for third cost center).

I saw another thread to linked to a concatenate example by Allen Browne, but that places multiple values in a single cell. I want different columns per cost center.

View 2 Replies View Related

Queries :: Query To Show As A Single Line Item

Apr 8, 2013

Access Database in which i download the table from an Excel file.I am looking to create a query with certain criteria but did not have any luck recently.

1) I will need the query to show <Short code> that are only unquie to Korea.That means shortcode with a count of 1 belonging to Korea only.

2) I will need the query to show as a single line item <Shortcode> that appears two times under the country Korea. For example short code CB01406 is shown as two rows, i will like it to only show as a single row.

3) For all other shortcodes which exist in China as well as in Korea or China only. I will like them to be hidden in the query. That means not shown at all.

View 7 Replies View Related

Modules & VBA :: Insert Into Function - How To Carry Over To New Line

Oct 24, 2013

I am using "INSERT INTO tablename(a1,a2)" function but i have to many "a" objecjts. How to carry over to a new line without having error?

View 10 Replies View Related

Queries :: Search For Multiple Plot Numbers Preferably In One Parameter Prompt With Comma To Separate Numbers

Aug 12, 2014

I'm having multiple problems with my database like things such as -

i'm currently working on the Query 2 - On the Phone database (ignore Query 1) and i want to search for multiple plot numbers preferably in one parameter prompt with a comma to seperate numbers. (this could be a multitude of numbers so i would like to be able to input as many as needed). Also when i do search on this query since the Criteria is a 'Between' Value i would expect everything between the 2 numbers input to show up - but a lot of numbers out of the range show up too - why is this? (The Numbers are like "69 to 136" and they will show up - but 1-69 and 136-170 would too

I would also like to implement the search results from Query 2 into the Form i currently have made but it just opens up a access table when the search is made?

i cannot link my database as it is too big for the server - But here are the Criteria for Query 2:

Plot No - (criteria = Between [Enter First Plot No:] And [Enter Last Plot No:])
Site - (criteria = Like "*" & [Enter Site:] & "*")
Product - (criteria = Like "*" & [Enter Product:] & "*"

The Query is the one im most concerned about , i can live without a form.

View 14 Replies View Related

Queries :: Crosstab Query That Keeps Each Contract On One Line And Separate Fields For Each Contact

Jun 4, 2014

I have two tables, and I'm trying to create a crosstab query...I think. One table is Contracts, one is Contacts. Each contract could have multiple contacts, but they are numbered (1, 2, 3...etc.) based on importance. I want to create a query that keeps each contract on one line, and separate fields for each contact and each field of the contact. So a contact will have Title, First, Last, Address, etc. So I want my query to show as follows:

Code:
Contract-----Title1-----First1-----Title2-----First2
ContractX Mr. James Mrs. Sally

I of course need this to be dynamic, so if a contract has 9 contacts, there are fields up to Title9, First9, etc.

View 7 Replies View Related

Modules & VBA :: Loop Function Repeating First Line Of Recordset

Aug 17, 2015

managed to get some code up and running but when trying to enhance it I have hit a rut.

I have a function that is looking up a query called Optimisation - Auto Optimise with operational data in it. I only need 2 key fields; consolcode and volume. There are 106 records with different consolcodes each with different volume. e.g consolcode: Chittagong to Rotterdam201452 (Chittagong to Rotterdam by year "2014" by week "52") and volume 161 (cbm)

I then run a code that allocates the volume into specific sea freight containers and returns the values into a different output table.

The allocation code works fine but when I run the loop function for the recordset rsttradelane it runs for the correct amount of records (106) but always returns the first record of Chittagong to Rotterdam201452 and 161 cbm and not the other 105 consolcodes with the different cbm. Giving me an output table with Chittagong to Rotterdam201452 and 161 cbm repeated 105 times!!

Code:
Set rsttradelane = dbsEPIC.OpenRecordset("Optimisation - Auto Optimise")
consollane = rsttradelane!consolcode
ConsolVol = rsttradelane!Volume
Do Until rsttradelane.EOF
'Optimisation code' then
Code:
rsttradelane.MoveNext
Loop
rsttradelane.Close

How do I ensure that each consolcode and its associated cbm is recognised individually and flushed through the optimisation code?

View 3 Replies View Related

Queries :: Subtracting Stock Numbers With A Query

Jan 2, 2015

I'm creating a sales system that allows customers to place orders using a customer account. when a customer completes an order the number items in the order needs to be subtracted from the stock numbers of each of those items stored in the system.

What I have so far is zipped and attached,

The way my system works should be easy enough to understand, there are four linked tables that store information on customers, products and orders. What I'm really struggling to understand is how to take the values in the records in the Invoice-Product table and take them away from the stock numbers for the products in the products table. But only new orders should take away from the stock number when a new order is placed.

If possible I also need to be able to add stock numbers for example if a delivery comes in, and if it's similar enough could that also be done here?

View 4 Replies View Related

Queries :: Simple Query To Find Records Which Are Not Numbers

Jun 1, 2015

I have an table that contains StudentID, Name and Age. I have imported the data from Excel sheet and there are some records which contains Null Value and some "h", "n/a" etc. I would like to design query which finds the records that are non numeric.

View 2 Replies View Related

Queries :: Using Query To Extract Data Based On Numbers

Feb 18, 2014

I have a table with a field named BinNo which has a list of items with a bin no in the format 1.234( this number can be any number up to 6000.9999).

Is there a way for me to have a field on a form where I enter a number (i.e 1) and it lists all the items with a 1 before the decimal point but not 10 or an other number with a one in it. If I enter 10 then it will only give me the items with 10 before the decimal point and not 11 etc.

I have a query that pulls all the data into it but I only want the query to show the items relating to the number I enter into the form field.

View 2 Replies View Related

Reports :: TRIM Function For Numbers

Jun 13, 2014

I have a report that contains several numeric fields for Blood tests. I am currently using the "TRIM" function to great success in the following format

=Trim("Last Bloods: " & [dtmBloodsLast] & " Hb " & [intHb] etc.....

However When I try to Bracket out any fields that do not have a value in the table I get a #Type! Error

e.g: Trim("Last Bloods: " & [dtmBloodsLast] & (" Hb "+[intHb]))

Where intHb is a Number, field Size: Double, Format: General numberSimilarly I have one or two fields which have + - characters in their name e.g. intCa2+ (Calcium) which seem to throw a type error (inconsistently).how I can achieve "skip this field if no value in the table - but display with Indicator (e.g. Hb for Haemoglobin) if value present".

View 4 Replies View Related

DateDiff Function Giving Results With Numbers Way Too Large

Dec 28, 2007

I am finishing up a database that logs basic activities/tasks for my coworkers. As they go in to the database and log an activity in it stays open until they end their day or they start a new task. All this works fine, but the problem comes when I try to determine the total time spent (in hours) on each activity/task. I have written similar queries before and they worked just fine, but for some reason I am having trouble getting this one to work. Here is the expression I'm using...

Time Diff (in hrs): DateDiff("h",[Sample_TM_Table_1]![Time_In],[Sample_TM_Table_1]![Time_Out])

Unfortunately, say Time_In = 8:32:38 am and Time_Out = 8:33:03 am
The expression says that is equal to 946632.

For another Time_In = 8:33:00 am and Time_Out = 3:18:19 PM.
The expression says this equals 946639.

I have tried changing the format of the date/time in both Time_In and Time_Out fields to ensure they were the same and cross checked the expression but still get the same answers each time. Even when I try to use "n" for the interval or "s" it is still highly incorrect. The only thing that makes me think I still have a formatting issue is that the Time_In shows a long date on the results table while Time_Out shows it in a general date format. However, when I go into both the table and the queries to check the formatting they both show general date. Any ideas? I'm all out! Thanks in advance.

View 2 Replies View Related

Queries :: Update A Query Based On Results From Another Query Using Count Function

Apr 2, 2013

I run a physical therapy office and patients come in for treatment either 3, 4 or 5 times per week. My database is used to track these frequencies (among other things).

I have 3 queries which count how many patients come in 5, 4 and 3 times/week.

In my main table I have fields called "how many 5's", "how many 4's" and "how many 3's".

I have tried to design an update query which will update those fileds in my main table to reflect the counts in the 3 queries mentioned above.

(I'm not using SQL view, I'm using the query design view)

In the "update to:" row, I use the Build function and locate the count I'm looking for.

Problem: when I run the query I get the error: Operation must use an updateable query.

View 3 Replies View Related

Queries :: Using If Function For Query

Oct 11, 2013

I have a query driving a report that fills in the on time or late based on comparing the release date to the production due date. The code works except for if we haven't released it yet and the release date is void. I need it to then check versus today's date and then populate the late/on time. But I need this to take a back seat to if both fields are populated. Here is the code I am currently using and I have attached a screen shot of the query with the 2 boxes highlighted in red.

On Time / Late Eng: IIf([Released to Prod]<=[Prod Due Date],"On Time",IIf([Released to Prod]>[Prod Due Date],"Late",""))

View 7 Replies View Related

Queries :: Max Function In Query By Row Not Column

Apr 3, 2015

I have a table that holds the dates of various approvals for documents.

Approval DatesDocumentID
ApproverA_DateApproved
ApproverB_DateApproved
ApproverC_DateApproved
LastUpdated

In a query, I'd like there to be a column with the date of the most recent approval (max date) for each document. Using the following formula in the Expression Builder gives me the error below.

Code:
Name: Max( [Projects]![ApproverA_DateApproved],[Projects]![ApproverB_DateApproved],[Projects]![ApproverC_DateApproved])

"The expression you entered has a function containing the wrong number of arguments"

How can I get the most recent date a document was approved by any approver?

BTW - I initially thought I could just use the date the record was last updated. However, sometimes people remove their approval. This causes the LastUpdated date to be wrong (for this purpose), since it then reflects the date they removed their approval, not the most recent date that someone gave it.

View 3 Replies View Related







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