Adding 'Autonumber' To Query On The Fly.

Jun 21, 2007

Hi all,
I have this select query that pulls out the last 13 distinct values in in descending order from a table. However in order for me to play with these values I need an ID number and ideally i'd like to do this on the fly rather then do a make table and then use that.
Is there any way of adding a 'autonumber' column to a select query on the fly in so that it can be used as reference ?

Thanks in advance,
Mitch...

View Replies


ADVERTISEMENT

Adding Prefix To Autonumber?

Jul 27, 2006

So I have a table with a bunch of data, InventoryID is the autonumber field which just increments normally, what I want to do is stick 'S000' in front of the autonumber, and for this to be the default prefix for any new items in my database - how would I go about this? I'm guessing some kind of append or update query would do it, but I'm no access whiz, help appreciated folks.........

View 2 Replies View Related

Adding An Autonumber Field Automatically

Apr 27, 2007

Hi,

Can somebody help...
I'm trying to put via an automatic way a field to a table that autonumbers. When I use a select-query: ALTER TABLE tablename ADD COLUMN Id Autonumber, Access doesn't recognizes the type "Autonumber". Even in VBA when I use the .createfield method, I can't set the datatype "Autonumber". I'm pretty sure it must be possible (as access can store anyway the indexes.. actually, I want those indexes as numbers in a separate field).

Thanks a million for any help!!!
Leen

View 2 Replies View Related

Adding AutoNumber As Primary ID To Existing Table

Jan 31, 2012

I have a simple database that I inherited, that contains basic customer contact info. We want to start adding more functionality to the database, so I've done alot of research to learn about how to begin normalizing my data.The existing table does not contain a useful primary key, since we may have multiple individuals from the same company, companies with very similar names, etc.

I would like to add an AutoNumbered field to use as a CustomerID/primary key, but I can't seem to find a way to do so. Here is what I've tried so far:

I have tried to add a field to the table, and make it an AutoNumber data type. When I do so, I can error message saying that I cannot make a field AutoNumber if any other field in the table already has data entered in it.I have tried to create a new table containing only an AutoNumber PrimaryID field, and then import data from the existing table, but that just creates a 3rd table.

View 1 Replies View Related

Controlling Autonumber Field - Start Autonumber From 1 Everyday (Composite Key)

Nov 21, 2013

I have two tables linked to each other in one to many relationship. Instead of auto number, the date and shift (Text) is being used as the primary keys (Composite Primary Key). Here is the tables structures,

Payouts Table:
Date: Primary Key
Shift (Day or Night) : Primary Key

Bills Table:
Date: Primary Key
Shift (Day or Night): Primary Key
Autonumber: Primary Key

The tables Payouts and Bills has one to many relationship. One payout row can have many bills. The problem is that I want to start the Autonumber in bills table everyday from 1. As date and shift are different for every day so even if i start bills from 1 everyday, it wont make same primary key. I can do it manually but I want to make it automatically.

View 4 Replies View Related

Autonumber Query

Jan 27, 2007

Hi. I have to create a autonumber sequence that restarts when there is a change in a previous column of the table. An example of what I am trying to achieve is:

blue 1
blue 2
blue 3
green 1
pink 1
pink 2
red 1
red 2
red 3
red 4

I would appreciate any advice how this can be done. Thankx.

View 1 Replies View Related

Update Query And Autonumber

Aug 19, 2005

Hello access friends,
the following update query UPDATE Screen SET Screen.ScreenID = [CarModel] & "-" & Left$([Category],1) & Format(100,"000"); gives me duplicate values. How to avoid this and increment the next number?
I have attached the database to show what I wanted to achieve in the form.
with many thanks for your help.

View 7 Replies View Related

Fake Autonumber In Query

Jul 17, 2006

How can I create a fake autonumber in a query? I have a set of data that have their own individual number but I would like to sort them by date and then run a dsum() based on the FAKE autonumber.

-Alex

View 5 Replies View Related

Can I Add An Autonumber Field To A Query?

Sep 9, 2004

I would like to create a query that has a new autonumber field. Any suggestions or add-ins available? Thanks.

View 6 Replies View Related

Autonumber Column In A Query

Sep 23, 2004

Is there a way to add a column in a query with an autonamber
function ? What I need to achieve, is to assign a unique number to
identify each row of the query.

View 1 Replies View Related

? Create An 'autonumber' In A Query Result

Apr 18, 2006

Hi,

example:

SELECT tblFalls.Guest_Name, [Account_Number], Count(tblFalls.Account_Number) AS Falls
FROM tblFalls
GROUP BY [Account_Number], [Guest_Name];

Gives me:

Smith, Joe; M698, 1
Blinke, Frank; M686, 2
Neal, Bobbie; M648, 1


I need ot to give me,

1, Smith, Joe; M698, 1
2, Blinke, Frank; M686, 2
3, Neal, Bobbie; M648, 1

each time i run the query i need to list that guests, their number of falls and assign each unique guest a number starting with 1 on up...

How?
yes, yes, i know how to do it in a report, but I need right now to be able to do it in a query alone.. anyone?

I tried:
SELECT Sum(1+), Guest_Name, Account_Number, Count(Account_Number) AS [Falls]
FROM tblFalls
GROUP BY Account_Number, Guest_Name;

=p no luck.. though it looks neat.

I also tried writing a function

Public Function GetQryNum() As Integer
If IsNull(gQryNum) Or gQryNum < 1 Then
gQryNum = 1
GetQryNum = gQryNum
Else
gQryNum = gQryNum + gQryNum
GetQryNum = gQryNum
End If
End Function

SELECT GetQryNum() AS GuestIndex, Guest_Name, Account_Number, Count(Account_Number) AS [Falls]
FROM tblFalls
GROUP BY Account_Number, Guest_Name;

But all i get is a '1' in every row.

Any ideas?

View 11 Replies View Related

Fake An Autonumber Field In A Maketable Query

Jul 15, 2006

Hi Guys,

8 posts on the subject over a number of years and the answer seems to have been no, you can't have an auto number field in a maketable query.

Is there any reasonable way to create a sequential count of the records shown in the maketable query, not the underlying records?

Background:
I have a maketable query that selects fields from 2 tables which are ordered in a specific way. The sigma button is clicked to reduce this recordset to unique entries and this is what goes into the created table.

This newly created table is a row heading for a pivot table query and I want it ordered by the method used in the query. An autonumber or some method of counting/incrementing the records would do the trick.

I am currently creating the table and then adding the Autonumber field manually, which is hardly a solution at all. :confused:

An afterthought before I post: The reason I want the autonumber field is that the pivot table shows the records in alphabetical order rather than the order the table holds the records. Is there any way of forcing the pivot table to use the records as ordered in the table. A note of caution here, I get very confused when dabbling with pivot tables. :eek:

Any thoughts/solutions welcomed. And if I'm asking the wrong question, let me know! :)

View 3 Replies View Related

Problem With Append Query And Autonumber Field

May 1, 2008

Hi everybody,

I am appending the information I have in one table to another. The first table's name is Videos and it only has 5 records. When I append the information from the other table which has some of the fields of the Videos table (but doesn't have a primary key), the new records in the Videos table have as primary key value (the autonumber field) values that start from 44699657. Why is this happening?

View 2 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

Adding Tax To Query

Mar 16, 2006

I have developed a query which adds accumulated costs for each client in my DB, I am having trouble adding the VAT tax which is 17.5% to the query though, I seem to get a lesser total once tax is added which can't be correct.

Here is my query:
SELECT DISTINCT Holiday_Bookings.ClientID, Holiday_Bookings.Booking_Cost, Room_Facilities.FacilityCost, Rooms.[CostPerNight], Rooms![CostPerNight]*Nights_Stayed+Holiday_Bookings!Booking_Cost+Room_ Facilities!FacilityCost AS TotalCost
FROM Room_Facilities INNER JOIN (Hotels INNER JOIN (Holiday_Bookings RIGHT JOIN Rooms ON Holiday_Bookings.ClientID=Rooms.ClientID) ON Hotels.HotelID=Rooms.HotelID) ON Room_Facilities.FacilityID=Rooms.FacilityID;

View 3 Replies View Related

Help Adding Something To This Query

Mar 23, 2006

I have a table called DSERDBA_CASE_STATUS_CHANGE and it contains the following fields:

DSERDBA_CASE_STATUS_CHANGE.STAT_CASE_ID,
DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE,
DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE,
DSERDBA_CASE_STATUS_CHANGE.STAT_FROM_CASE_STATUS,
DSERDBA_CASE_STATUS_CHANGE.STAT_TO_CASE_STATUS,
DSERDBA_CASE_STATUS_CHANGE.STAT_USERID,
DSERDBA_CASE_STATUS_CHANGE.STAT_ACTIVITY_CODE,
DSERDBA_CASE_STATUS_CHANGE.STAT_COMMAND,
DSERDBA_CASE_STATUS_CHANGE.STAT_REASON_CODE

I’m looking to find CASE_ID's where the BEGIN_DATE is greater than 09/30/2005 and less than 10/01/2006 where the CASE_STATUS went from O to C and where the STAT_REASON_CODE does not equal INT27 and I have come up with this query which works fine.

SELECT
DISTINCT
DSERDBA_CASE_STATUS_CHANGE.STAT_CASE_ID,
DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE,
DSERDBA_CASE_STATUS_CHANGE.STAT_END_DATE,
DSERDBA_CASE_STATUS_CHANGE.STAT_FROM_CASE_STATUS,
DSERDBA_CASE_STATUS_CHANGE.STAT_TO_CASE_STATUS,
DSERDBA_CASE_STATUS_CHANGE.STAT_ACTIVITY_CODE,
DSERDBA_CASE_STATUS_CHANGE.STAT_COMMAND,
DSERDBA_CASE_STATUS_CHANGE.STAT_REASON_CODE

FROM DSERDBA_CASE_STATUS_CHANGE

WHERE
(((DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE)>#9/30/2005# And
(DSERDBA_CASE_STATUS_CHANGE.STAT_BEGIN_DATE)<#10/1/2006#) AND
((DSERDBA_CASE_STATUS_CHANGE.STAT_FROM_CASE_STATUS )="O") AND
((DSERDBA_CASE_STATUS_CHANGE.STAT_TO_CASE_STATUS)="C") AND
((DSERDBA_CASE_STATUS_CHANGE.STAT_REASON_CODE)<>"INT27"));

My problem is that I also want to exclude cases where the case went from CASE_STATUS C to O on the same date that it went from O to C (it closed and reopened on the same day) And I don’t know how to adjust this query to accomplishment this.

Can someone show me how? Thanks

View 1 Replies View Related

Adding A Row To The Query

Aug 3, 2006

hallo everyone,

i have the following query and i am getting the following output

SELECT Sum(tbl_RFQ_Details_AVOB.[AVOB RFQ]) AS [SumOfAVOB RFQ], tbl_Status.Status
FROM tbl_Status LEFT JOIN tbl_RFQ_Details_AVOB ON tbl_Status.ID = tbl_RFQ_Details_AVOB.Status
GROUP BY tbl_Status.Status, tbl_RFQ_Details_AVOB.Status;


SumOfAVOB RFQStatus
16900110RFQ in Process
12610000Under Review
1200000 Decided
3500000 Terminated
1000000 Terminated Supplier
6000000 Leverage Back
40000000Uncompetitive
500000 RFQ in Preparation


Now i require a new line in addition to this that says that the total value is and the sum of those values must be given.

required output:

SumOfAVOB RFQStatus
16900110RFQ in Process
12610000Under Review
1200000 Decided
3500000 Terminated
1000000 Terminated Supplier
6000000 Leverage Back
40000000Uncompetitive
500000 RFQ in Preparation
totalvalue Total RFQ

How can this be done?

regards,
aravind.s

View 1 Replies View Related

Adding Query Fields Together

Nov 10, 2005

My company has a microsoft access table with about 1200 IDs containing names, addresses etc.
Now I want to print this out in an excel sheet because I want to create address stickers, but I want every cell in the excell sheet to add information about the columns in the database together. I might be very unclear, let me demonstrate what I mean:
The Acess file might look like this:
id | name | address
1 | john | Street 01
2 | sara | Street 02

Now I want to have 2 excell cells which contain the information like this:
name_address
name_address

In my example, 2 cells with the following information:

john Street 01
sara Street 02

So I dont want 4 cells, I want to add the information together from 1 Id to 1 cell, but I also want to add linebreaks to it, It must eventually become an address sticker

How can this be done?

View 3 Replies View Related

Need Help Adding Query To Table?

Nov 23, 2005

Hi All,

I am trying to add the infomation from a query and place it in a table so that I can use that data to build a Union Query that plots onto a chart.

Heres what I have:
Dim qDef As DAO.QueryDef
Dim SQL As String

Set qDef = CurrentDb.QueryDefs("QryBaseline")

SELECT tblAudio.AudioID, tblAudio.PatientID, tblAudio.AudioDate, tblAudio.Type, tblAudio.L500, tblAudio.L1k, tblAudio.L2K, tblAudio.L3K, tblAudio.L4K, tblAudio.L6K, tblAudio.L8K, tblAudio.R500, tblAudio.R1k, tblAudio.R2K, tblAudio.R3K, tblAudio.R4K, tblAudio.R6K, tblAudio.R8K
FROM tblAudio
GROUP BY tblAudio.AudioID, tblAudio.PatientID, tblAudio.AudioDate, tblAudio.Type, tblAudio.L500, tblAudio.L1k, tblAudio.L2K, tblAudio.L3K, tblAudio.L4K, tblAudio.L6K, tblAudio.L8K, tblAudio.R500, tblAudio.R1k, tblAudio.R2K, tblAudio.R3K, tblAudio.R4K, tblAudio.R6K, tblAudio.R8K
HAVING (((tblAudio.Type)="BL")) AND (((tblAudio.PatientID)=[Me]![PaiteintID]));

I have a "tblEvaluate" that I want to store the above selected record.

I am not sure whether to add and Delete, OR Edit and Update?

How do I get the above information into the table - "tblEvaluate"?

I know it's simple, I just have a mental block!
Thanks for you help....ENVIVA

View 3 Replies View Related

Adding Values In A Query

Sep 28, 2005

can someone help with this. I have 2 fields in a query

tbl1_nbil = 3
tbl2_nbil = 0

however when I add them using

Bill = [tbl1_nbil] + [tbl2_nbil], I only get a few of the added numbers in the calculated field. In some records it works, but in the majority it does not

It onl seems to add when both fields are greater than zero

tbl1_nbil : tbl2_nbil : Bill
1 : 1 : 2
1 : 0 : 0
2 : 1 : 3
0 : 2 : 0
4 : 0 : 0

View 1 Replies View Related

Adding A Field Name To A Query

Nov 30, 2005

I hope I can ask this question so that it makes sense.

I have a totals query that I'm using to make a Chart. The query works fine but I want to change the look abit. What I'm doing is quering a table looking for the total number of times that there is a check box in a field called PDC RTA and totaling the Hrs as well. The data comes back looking looking like this.
PDC RTA-----Count-----Total Hrs
-1 ---------- 6 -------- 53
0 -----------25 -------- 78

My problem is that when I chart this the -1 and 0 show up at the bottom of the bars on the chart. I would like to rename these to fields on the qry qrid then I can chart the new field names so that it will make sense to the user.

Make sense

Jon

View 2 Replies View Related

Adding Iif To Query Or Table

Mar 15, 2006

Hello folks first post here. I tried reading through the boards to find someone with a similiar question, but not luck yet. I have been working with a basics of Access for about a year. I did take take a bit of programming in college but I don't remember much of it, so I looking for a little help. I can usually Google for answers but I cannot seem to find the write key words this time.

A while back I created a table that tracks employees' data and recently I started working with the insurance data I have gathering for sometime.

It goes something like

Field Name Data Type

SS# Number (primary key)
Insurance $ Number
PPO YES/NO
HMO YES/NO
Self YES/NO
Spouse YESNO
Children YES/NO
Family YES/NO
Dental Self YES/NO
Dental Spouse.......etc.


What I'm trying to do is turn the yes/no's into total dollars for each person. I have done this in Excel but the fields were differnet and I had to use a many, many if.'s or a lookup table(data array)

PPO doesn't = a dollar amount by itself, but PPO + Self = $19.03 or PPO + Self + Dental Self = $23.00. Or the person can just have Dental Spouse = 8.86. Pretty much the people can take a piece and leave another.

"Insurance $" is another field name and is where I am trying to get the total to go.

I was thinking of a lookup table but I don't know how to do that in outside of Excel.

I am thankful for any help or even a nudge in the right direction.

~Profector

View 4 Replies View Related

Adding Comments To An SQL Query

Apr 12, 2006

How can I add comments in an SQL Query mode? ",',?, ; None of these work with text following them.

View 1 Replies View Related

Adding A Combo Box To Query

Aug 2, 2006

Hi,

I'm trying to add a combo box to my query so when I select the item from the combo box it executes my query. I don't know where to begin... Any help??

View 7 Replies View Related

Adding In A Query Problems

Dec 4, 2006

Hi,

I have a problem thats really hurting my head and probably has a simple solutions. Please help!

Basicly, I have a query that adds to fields that are numbers, which works fine but when one of the fields is 0 it doesnt add, it just leaves it blank. I have used the nz function in my first 2 fields as some of them are blanks. My calcuation field is simply like:

[returned]+[loaded]

but I get:

Returned Loaded total
0 2


I tried wrapping the nz around my calculation but that gave me like this:

Returned Loaded total
0 2 02
7 8 78

Help! Why doesnt it add 0 and 2 to make 2?

Any help might save my sanity or computer screen.:mad:

Cheers.

View 2 Replies View Related

Adding Quantities In A Query

Sep 7, 2007

I have a field, quantity, which i want to add all the quantities together to show a total. I want to do this using a query as i will use this total for other calculations. When in the query, i have selected "sum" in the totals column in the quantity. What do i need to do extra? I am not getting any results at the moment.

Emily

View 2 Replies View Related







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