473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Consecutive numbers

Greetings

This should be easy, but I am stuck!

I have a table that I import from another program. There are 25
fields, but I only need to use 3 of them for what I need to do. After
I import the data, using ODBC, the primary key is multi-field; fieldA,
fieldB, fieldC.

fieldA is a "Job Number", in text format. fieldB is a number field
with a "width", fieldC is a number field with a "length".

csv example; "43758A", "24.75", "32.25"

There are anywhere from 1, to 50 records having a unique "Job Number",
("fieldA").

I want to create a new table in my database, for use throughout my
application. I would use an Append Query, or VBA code, to update the
table periodically. The table will contain fieldA, fliedB, fieldC. I
will sort on fieldB, ascending.

The new table would contain another field; "fieldLineNo". The value
for that field needs to be 1 for the first record, then 2, 3, etc
until the value of fieldA changes. Then the consecutive numbers start
over.

end result:

"43758A", "12.75", "32.25", "1"
"43758A", "13.75", "32.25", "2"
"43758A", "14.75", "32.25", "3"
"51789A", "9.75", "32.25", "1"
"51789A", "10.75", "32.25", "2"
"51789A", "11.75", "32.25", "3"

Can anyone help me out here? I am sort of new to Access and VBA, but I
can usually get stuff working with a little push in the right
direction.

Thanks,

Dennis
Nov 12 '05 #1
2 4222
In the append query, use an expression similar to the following as the
calculated field that appends to the fieldLineNo field (this expression
assumes that the "source" field name is the same as the target field name
(that is, fieldA):

Field4Value: Nz(DMax("fieldLineNo", "TableNameToWhichDataAreBeingAppended",
"fieldA='" & [fieldA] & "'"), 0) + 1
--
Ken Snell
<MS ACCESS MVP>

"Dennis Ruppert" <dr******@ruppertweb.com> wrote in message
news:f7**************************@posting.google.c om...
Greetings

This should be easy, but I am stuck!

I have a table that I import from another program. There are 25
fields, but I only need to use 3 of them for what I need to do. After
I import the data, using ODBC, the primary key is multi-field; fieldA,
fieldB, fieldC.

fieldA is a "Job Number", in text format. fieldB is a number field
with a "width", fieldC is a number field with a "length".

csv example; "43758A", "24.75", "32.25"

There are anywhere from 1, to 50 records having a unique "Job Number",
("fieldA").

I want to create a new table in my database, for use throughout my
application. I would use an Append Query, or VBA code, to update the
table periodically. The table will contain fieldA, fliedB, fieldC. I
will sort on fieldB, ascending.

The new table would contain another field; "fieldLineNo". The value
for that field needs to be 1 for the first record, then 2, 3, etc
until the value of fieldA changes. Then the consecutive numbers start
over.

end result:

"43758A", "12.75", "32.25", "1"
"43758A", "13.75", "32.25", "2"
"43758A", "14.75", "32.25", "3"
"51789A", "9.75", "32.25", "1"
"51789A", "10.75", "32.25", "2"
"51789A", "11.75", "32.25", "3"

Can anyone help me out here? I am sort of new to Access and VBA, but I
can usually get stuff working with a little push in the right
direction.

Thanks,

Dennis

Nov 12 '05 #2
Thanks for the response. I must be doing something wrong, as I get a
result of 1 for every record in the appended table. My test:

tblSource has 4 fields; Job, CutLineNo, SOLineNo, DoorWidth

tblResult has same 4 fields, plus a field named LineNum

Entered as Expression:

LineNum: Nz(DMax("LineNum","tblResult","Job='" & [Job] & "'"),0)+1

I tried this as a select query, and as an append query. I added the
tblSource in the QBE, and included all 4 fields along with the
calculated field.

Where did I go wrong?

Thanks again,

Dennis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Adam | last post by:
Hi, I am trying to mark consective numbers in a data set and get a count as to how many consecutive numbers exist in the a given line of data. Here is an example line: 3, 5, 7, 9, 10, 13,...
10
by: ChrisD | last post by:
I'm trying extract a count of consecutive numbers, or "unbroken" years in this case, at any particular given time. For example (simplified): CREATE TABLE #Customers ( CustNo INT, YearNo...
2
by: Iwilfix | last post by:
I am completly new to Access. I need a field to automaticly enter invoice numbers that run consecutive. For example records starting with an invoice # 1276, would autmaticly go to #1277 and #1278...
0
by: Dennis Ruppert | last post by:
Greetings This should be easy, but I am stuck! I have a table that I import from another program. There are 25 fields, but I only need to use 3 of them for what I need to do. After I import...
9
by: boliches | last post by:
I have a seperate table to generate consecutive numbers. Using "Dmax" to find the largest number to increment . My problem is that I want the number to begin at 1000 at the start of each month,...
11
by: xctide | last post by:
This project will give you more experience on nested for loops and user-defined functions. The original project came from an IT company’s programming test where they were asking for the most...
7
by: Sharkie | last post by:
I need a regular expression which will evaluate to false if number of consecutive characters (non-whitespace) exceeds certain number (10 in this example). For example, I have this function: ...
8
by: help2008 | last post by:
Hi I have been doing this working on an assignment for the last week and have stumbled across a part which I cant get my head around. I was hoping that someone could explain what I am missing. I...
2
bwesenberg
by: bwesenberg | last post by:
I am not sure how to explain this so I will try to the best of my ability. I need to be able to produce 1000 labels from access that are based on consecutive numbers that Access will produce. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.