I have this table called: "ABC" and inside it are four fields: "SKU" (DataType: Short text), "VID" (DataType: Short text), "Cost" (DataType: Currency) and "Qty" (DataType: Number). -
SKU VID Cost Qty
-
123 545 $5 9
-
123 545 $5 25
-
145 441 $4 45
-
488 874 $7 4
-
474 457 $8 5
-
145 441 $4 47
-
I want to add another field/column called "Line #" that shows the row number so the table will look like this: -
Line # SKU VID Cost Qty
-
1 123 545 $5 9
-
2 123 545 $5 25
-
3 145 441 $4 45
-
4 488 874 $7 4
-
5 474 457 $8 5
-
6 145 441 $4 47
-
I couldn't find any information on how to do this right because some rows have the same values.
Is there any way I can do this in either SQL or VBA?
8 2623
Is Line# (and PLEASE do not use "#" in the field name!) a unique identifier for each record? If it is, just add a Field to the Table, with AutoNumber Data type, and it will add numbers to all your records.
If this field is not a unique identifier, what is it used for and which rows would have a duplicate Line#?
It is a unique identifier but I don't like using AutoNumber because if I delete a row, than the number skips. Take this table for example: -
LineNumber B C
-
1 cd sd
-
2 cd sd
-
3 ef df
-
4 cd gb
-
Now if I want to delete line number 4, then add more rows here's what happens -
LineNumber B C
-
1 cd sd
-
2 cd sd
-
3 ef df
-
DELETED
-
Now that I deleted that row, let's say I want to add a row with values for B is "if" and for C it's "wq" -
LineNumber B C
-
1 cd sd
-
2 cd sd
-
3 ef df
-
5 if wq
-
It skips line 4 and goes to line 5.
If it's not possible to make a query or a module that creates [LineNumber] for me? Or should I just suck it up and enter each line in manually?
Are you wanting to add the field to the table or just in a query to get a row number in the query results?
**Edit** Sorry, I didn't refresh before posting, so I didn't see post #3.
Jrod,
There is nothing wrong with having missing row numbers. It happens all the time in databases. What happens if you were to change one of your items? Then you would delete it. Would you then renumber all of your other records, just because one of the items was deleted from the inventory?
I know, I am OCD myself, so having missing record numbers causes my head to screw into the ceiling, but I have learned to get over it. Don't over-complicate something that the DB will easily and happily uncomplicate for you.....
I'm not trying to sound rude or anything but I do need the line numbers to be in correct order. It has nothing to do with preference.
This table is connected to a report which I'd need to print out once this is complete. It needs to show the line number on the left side for each row.
Is there a way I can show the line numbers on a report without using a query?
Ok I just looked it up and I fixed it by creating an unbound textbox and in the property sheet under the "Data" tab I have:
Control Source =1
Running Sum Over All
Thanks for the advice and help
Jrod, no rudeness was taken. I hope you did not consider my comments rude, either. Sometimes they have to be in numerical order, and I can understand that necessaity from time to time.
I have done what you are asking before--since you are using it in a report, it would best be done in a query and not in a table, since there is no value in storing that value--if your inventory changes.
I have done this in the past, but my query is always sorting based on certain values, which is not what you have. I will have to do some lookinginto this one just a bit...
Ok. Glad you found an alternate solution.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sanjay Minni |
last post by:
What is the datatype to be used
for Primary Key columns for most
optimised access given that
- There will be a single column primary key only
- The values will only be integers (but as...
|
by: chris |
last post by:
What is the recommended way of storing 10 digit phone numbers? I like
bigint(10), but it seems most are using varchar? Or I've also seen 2
int columns, one for area code and another for the rest...
|
by: Moondog |
last post by:
I am referencing a datagrid item like this:
strItemNo = grdItems.Item(grdItems.CurrentRowIndex(), 0)
The Item Number is in the first column; column 0. It works fine
except this is not a...
|
by: Ronald S. Cook |
last post by:
I have tables in my database-based Web app like Player, Club, and
Tournament.
In each, I have an identity primary key column "ID" (1, 2, 3, 4.). I also
have a column "Number" which is a...
|
by: =?Utf-8?B?bWF2cmlja18xMDE=?= |
last post by:
Hi,
I want to display a serial number before every row in the datagrid. How can
I do that?
Thanx for your help.
|
by: sqlservernewbie |
last post by:
Hi Everyone,
Here is a theoretical, and definition question for you.
In databases, we have:
Relation
a table with columns and rows
|
by: meLady |
last post by:
Hello,
I have a form called feedback which has three columns and each cell in a column has a combo box that holds (Yes/No/Empty), and I want to count each column's value for example let's supposed...
|
by: NewlytoSQL |
last post by:
Hi all, im fairly new to SQL and im stuck half way through a query,
im using DB2 here is what im tryng to do.
i have a query that brings back an item number , shelf req, sum of all orders columns,...
|
by: dlite922 |
last post by:
This is again from the dynamic reporting module i'm building.
Columns come in and are built based on XML doc and the HTML (smarty template) does not know weather this is a number to format it...
|
by: Tillu |
last post by:
One of the column in a new table can be ename - varchar2(20) or
hase_code_ename - number(11) – Hash Code generated by JAVA.
We are going to create non-unique index on this column as one frequent...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |