473,396 Members | 1,599 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,396 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 4220
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.