Adding Autonumber columns into a Query Result

I searched the group message and i found a function below to create a
AutoNumber column for a Query result.

Creating an AutoNumber field from code
http://www.mvps.org/access/tables/tbl0016.htm

I dont know how i can run this code in my Query.

Name of the Query : Q1
Field Name: Quantities

I would like to have additional column named ID which will be produced
by this code.

Can you help me?

0
mezzanine1974
3/27/2007 11:33:36 AM
access.formscoding 7494 articles. 0 followers. Follow

1 Replies
13263 Views

Similar Articles

[PageSpeed] 7

hi,

mezzanine1974 wrote:
> I searched the group message and i found a function below to create a
> AutoNumber column for a Query result.
> Creating an AutoNumber field from code
> http://www.mvps.org/access/tables/tbl0016.htm
You can't use it, cause it is used to create a field in a table.

> I dont know how i can run this code in my Query.
You need a key to order, then you can use this:

SELECT *, (
   SELECT Count(*)
   FROM QuerySource I
   WHERE I.Key < O.Key
   ) AS ID
FROM QuerySource O
ORDER BY Key

You may use the DCount() function instead of the subselect:

ID: DCount("*";"QuerySource";"Key<" & Key)


mfG
--> stefan <--
0
Stefan
3/27/2007 11:54:13 AM
Reply:

Similar Artilces:

Adding Blank Rows after the last Detail of the Report
Hi All, I've used this code from Dwayne: Private Sub Report_Page() Dim intNumLines As Integer Dim intLineNumber As Integer Dim intTopMargin As Integer Dim ctl As Control Dim intLineHeight As Integer intNumLines = 12 intTopMargin = Me.Section(3).Height intLineHeight = Me.Section(0).Height For Each ctl In Me.Section(0).Controls For intLineNumber = 0 To intNumLines - 1 Me.Line (ctl.Left, intTopMargin + _ (intLineNumber * intLineHeight)) - _ Step(ctl.Width, intLineHeight), , B Next Next End Sub My report needs to print blank rows (at least...

Adding hyperlinks with parameters
Hey everybody I have a batch file which needs to be run from an excel sheet with a parameter, like this: c:\1.bat myParameter But when i try to run the Hyperlink, the Excel shows an error message saying it can't open the specified file (probably because the is a space between the file and the parameter) is there any known way to run the link from the excel? On Mar 2, 12:45=A0pm, Pasha <pavel_v...@mailto.mod.gov.il> wrote: > Hey everybody > I have a batch file which needs to be run from an excel sheet with a > parameter, like this: > c:\1.bat myParameter > But when i ...

outlook vcard, ad integration user properties
my boss is trying to get hix fax# in his vcard. he is using his address from the global address list I have modified his profile in active directory users and computers: I go into AD users and computers, double click on his user, go to the telephones tab, and enter his fax #. but when I did this his fax # is still not being pulled up in his outlook vcard. Does anyone know where outlook is trying to get this field from / how i can get this field into his vcard? thx ...

Text to Column #4
Hello, I have the following text in column A, which is one line: :! 10428712 ! NAME LASTNAME ! 20092004 ! 00458921 ! PMIAVW ! Is it possible with a VBA macro to create a column everytime there's "!" and to delete ":" Thanks for any help, You're going to have to find out what those characters are. I like Chip Pearson's addin: CellView http://www.cpearson.com/excel/CellView.htm to tell me those funny characters. Then you could use a macro to clean them up: Option Explicit Sub cleanEmUp() Dim myBadChars As Variant Dim iCtr As Lon...

ADDING A NUMBER
how do i add a number to a range of cells? I need to add 11.27 to a number of different cells each with a different number in them Put 11.27 in an empty cell, format it the same way as the numbers you want to add to, copy it, then select the numbers you want to add to and do edit>paste special and select add. -- Regards, Peo Sjoblom "Helpme" <Helpme@discussions.microsoft.com> wrote in message news:6D51344A-78E6-4377-B292-FC6C16FF6BA2@microsoft.com... > how do i add a number to a range of cells? I need to add 11.27 to a > number > of different cells e...

Why formula doesn't change on column insertion?
Hello: I know I will feel stupid when I hear the answer, but... If I have a formula ( =average(a1:a5) ), and I insert a new column, the formula, being relative, changes to ( =average(a1:a6) ). This works fine in a test. BUT I have a working spreadsheet in which inserting a column does *not* change the relative formula. Why? I can't see anything different in my working spreadsheet... -- Fred Boer Never mind - resolved. -- Fred Boer "Fred Boer" <fredboer1@NOyahooSPAM.com> wrote in message news:uin$VfrDIHA.5160@TK2MSFTNGP05.phx.gbl... > Hello: > >...

When adding attachments...
....in Outlook the following errors comes up: "Out of memory or system resources, please close some programs and try again" Quotas are fine. I have deinstalled/reinstalled Office, cleaned 'temp' areas, and many other tidbits. Any other ideas? Thanks. This might help as i had this problem with Outlook 98. Is the file you are trying to copy to attach nested in sub folders? if so try and copy the attachment to a root drive like c:\ Ignore previous email. wrong spellin if the attachment is nested in sub folders(this means you have to open different folders to get to ...

Masterpage Query
Hello Folks, I have many small items on the masterpage and find it can get quite frustrating sometimes when working on a document to have "This item is on the masterpage, to switch ..." all the time. Please can you tell me if it is possible to disable this message whilst still being able to view the masterpage items on screen. I know this is a long shot, but thought it would be worth a try anyway. Your help is and always has been very much appreciated. Thanking you in anticipation. -- Big Rick Hello Big Rick... Tools, options, User Assistance tab, uncheck Show tippages. -- ...

adding new records
I am totally new to CRM, so I hope this is really easy question: This concerns permissions.. I have a "sales" group, and with one of those people i need to be able to let them add new records on behalf of other "sales" people. Is there like a standard permission setting for it? (obviously every "sales" person can add new records if they select them selfs as the owner) thanks, Michal. Hi, By default the person who creates the record will be the owner. After record creation the person could reassign the record (manually) to another user. If all rec...

Help in Query with two condition
hello all, I have a table like this: Planner Qty User6 CUT SUB BAM-06 1 CONC Yes No BAM-06 1 CONC No Yes BAM-06 1 TOC Yes No BAM-06 1 TOC No Yes BAM-06 1 TACT Yes No BAM-06 1 TACT No Yes JAXM-06 1 CONC Yes No JAXM-06 1 CONC No Yes JAXM-06 1 TOC Yes No JAXM-06 1 TOC No Yes JAXM-06 1 TACT Yes No JAXM-06 1 TACT No Yes Note: CUT and SUB are check box I want a result as follow: User6 A B C D E F CONC 2 2 1 1 1 1 TACT 2 2 1 1 1 1 TOC 2 2 1 1 1 1 WHERE: A SUM Qty =BAM-06 B SUM Qty =JAXM-06 C SUM Qty =BAM-06 if Cut=YES D SUM Qty =JAXM-06 if Cut=YES E SUM Qty =BAM-06 if SUB=YES F SUM Qty =JAXM-06 i...

My column headers are numbers
Hello there, The column headings in my spreadsheet are numbers not letters. What have I done? Thank you in advance for your help. Judith Hi goto 'Tools - Options - General' and uncheck 'R1C1 Reference Style' -- Regards Frank Kabel Frankfurt, Germany "JudithJubilee" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag news:097301c4d871$66a88240$a401280a@phx.gbl... > Hello there, > The column headings in my spreadsheet are numbers not > letters. What have I done? > > Thank you in advance for your help. > Judith ...

Top 5 SQL in an Aggregate Query
I'm counting occurrences for Questions Grouped by Market Mgr and 3 different Area Mgrs. Taking "Top 5" in the SQL statement brings in the overall Top 5 records, which it should. I could run code to examine each Area Mgr (w/ the Market Mgr), build a Top 5 and add to a Table after deleting all those Table's records prior to examining each Area Mgr. Or..is there another way?? Any possibiliity the "Grouping" in an Access Report would display only the Top 5 for each Area Mgr grouping? TIA - Bob See: Subquery Basics: TOP n records per group at: http://a...

Picture Disappears When Added To Contact In Outlook 2003
Can someone help please. When I try to attach a picture to a contact in outlook 2003 immediately I double click the picture to be attached it disappears out of the outlook contact along with the placement holder in the form. Only when I right click the mouse and go remove picture do I get the placement holder back. I have looked at all the help menus but they offer no clues. Thanks TS ...

caps in columns
Hey Everyone, Is it possible to have an entire column that automatically formats so that all typed in letters are capital. If it is possible how would I go about doing this. thanks Chris go to google.com and look for free truetype fonts find an all-caps font install it use that font in excell (format.. cells... font) >-----Original Message----- >Hey Everyone, >Is it possible to have an entire column that automatically >formats so that all typed in letters are capital. If it >is possible how would I go about doing this. > >thanks >Chris > >. > Previo...

Criteria Parameter in query for two fields: help
I have a form that utilizes two contact lists in separate combo boxes to illustrate projects that multiple people have worked on. I am trying to make it so that a report will illustrate the associated data based on these contacts. The selection will be based on either one contact (from either list) or both. Whereby on selection, the report will generate the associated data based on these user names. How would I go about creating a parameter in the query so that it will limit the content to reflect either contact list or a combination of the two? I am a beginner to Acc...

Adding ActiveX to dialog with wrapper
When I add an ActiveX object to a dialog using the dialog editor - right click - insert activeX object, the help on the resulting activex selection tool states that a wrapper will not be added by using this method. If you need a wrapper, it suggests using the class view. This is using Visual Studio 2005. I'm having some problems with this on an existing project. To make sure I understand the process, I created a new MFC project, added a dialog, created a class for that dialog and added a Flexgrid object using the right click method in the dialog. I then added a variable for the flexgrid...

Filter for two columns
I have two columns Purchased Date and Depreciation Start Date. Can anyone help me to get the records with Depreciation Start Date greater than Purchased Date. Thanks Hi, sort with two conditions, highlight both columns, 1st condition Depreciation in descending order and as a 2nd condition Purchased in ascending order if this was helpful please say yes "Vadivu" wrote: > I have two columns Purchased Date and Depreciation Start Date. Can anyone > help me to get the records with Depreciation Start Date greater than > Purchased Date. > Thanks Use a helper col. As...

combination of stacked and clustered column
Hi! Any ways to combine two types of chars: sgtacked columns and clustered columns? B.R GmA If you stagger your data, you can create side-by-side stacked columns. Bernard Liengme has an example and instructions on his site: http://www.stfx.ca/people/bliengme/ExcelTips/Columns.htm and Jon Peltier has links to other sites with information: http://peltiertech.com/Excel/ChartsHowTo/ClusterStack.html Grigori Margolin wrote: > Any ways to combine two types of chars: sgtacked columns and clustered > columns? -- Debra Dalgleish Excel FAQ, Tips & Book List http:...

Adding alternate columns
I work on a schedule where I record ticket count and ticket sales for each show, listed chronologically. Column A = week ending date Column B = # Tickets sold for April 5 show Column C = Ticket Revenue for April 5 show Column D = # Tickets sold for April 9 show Column E = Ticket Revenue for April 9 show Column F = # Tickets sold for April 12 show Column G = Ticket Revenue for April 12 show Column H = Total # Tickets sold for all shows Column I = Total Ticket Revenue for all shows In the Totals columns, the Total Tickets formula is "+B4+D4+F4", and the Total Revenue f...

tally the difference between 2 columns
This is for surveys comparing before and after. For example, there are 2 columns below, 1st is before, 2nd is after 3,5 5,5 4,5 4,5 2,5 3,5 .... Is there a way I can calculate: total number of difference beween 2 columns for increase of 1, 2, 3, and 4 or decrease total number of each type of increase: ie. total 5 to 5, 4 to 5, total of 3 to 5, etc I've explored COUNTIFbut how do you have condistions in the criteria (column b - column a = 1) or mulitple conditions (column b - column a = 1 and column a = 4)? thanks for your help, Re: " total number of difference"... =SUMPROD...

sorting numbers in a column
Problem: The numbers I am sorting are composed of various numbers of integers, some having four digits, others five or six, and so on. I would like to have them sort by number regardless of number of digits. Will Excel let me do this? example: presently it looks like this: 3004 12001656 530393505 2200498378 and I really want it to sort like this: 12001656 2200498378 3004 530393505 Can this be done? -- kailuamike ------------------------------------------------------------------------ kailuamike's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29558 View...

A Simple Query problem?
I've wrestled with this one, but can't quite manage it! I have a tblStatement containing fields StatementID, Date, Description, and Value. For all records with Description = "NATWEST BANK", there are two values for each particular date. What I want to do is update the Description depending on whether the value is the Max or Min value for that particular date. I can use criteria with GroupBy and Min/Max in the query grid, but obviously cannot update the Description field as it is a GroupBy. And you won't be able to update anything if you use a GROUP BY or an ag...

Adding more than three Conditions to 'Conditional Formatting'
Can i add more than three conditions to the conditional formatting presets using code? Regards [Riz] -- Rizitsu ------------------------------------------------------------------------ Rizitsu's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15840 View this thread: http://www.excelforum.com/showthread.php?threadid=320382 Riz, as you have found out, only 3 conditions with conditional formatting. But yes you can use some code to get more than 3, try this it will change the cell color in column A when you put in one ,two, three, or four, right click on the she...

Upgrade to Great Plains Dynamics 9.0 error, Column PRODID not foun
Hello, I am attempting a test upgrade from Great Plains 7.5 to Dynamics 9.0 and I get an error during the system tables upgrade portion, right at the 'Load Additional Required Data' step. The error message is: The following SQL statement produced an error: delete from DU000010 where PRODID=258 followed by: ERROR [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'PRODID'. I checked the DU000010 table and the column does NOT exist. I also tried upgrading from 7.5 to 8.0, which worked, but when I then try to upgrade that 8.0 to 9.0, I still get the sa...

Adding fields from a different query
I have a form built based on a main query. How do I add more fields on that form that come from a different query? Anne A couple possibilities... Change your first query to include the extra fields. Use your second query to "feed" a form, then embed that form as a subform on your main form. Good luck! Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudoco...