473,416 Members | 1,739 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,416 software developers and data experts.

How to Compare Autonumbers and Return the Larger Value, and try to Assign it to a Bound Field

Hi everybody-

I have 2 tables, Hearings and Rulings. Both have primary keys called,
CaseID, that are autonumbers. I don't want both tables to have the
same autonumber. For example, if Hearings has 55, then I want Rulings
to have a number greater than 55. Two or more Hearings may be entered
before a Ruling is entered. For example, Hearings with CaseIDs= 55,
56, and 57 may be entered before a Ruling or vice versa. There is no
definite order. Hearings and Rulings can be entered at any time, in
any order. It all depends on when the users enter the Hearing and/ or
Ruling information.

I can get the maximum number by using the "Max" function. Right now on
the Hearings form, I use the Max function to get the highest/ biggest
autonumber for the Hearings table, i.e. Max([CaseID]). I tried using
the DMax function: DMax(expression, domain, criteria) but it didn't
work for me. Maybe I used it wrong because I didn't enter any criteria
because I'm unsure what criteria to use. But Access Help states that
the criteria is optional. I tried DMax([CaseID], Hearings table) but
it just returned the first/ lowest record number.

Anyway, I was thinking about using the Max function in a hidden text
box on the Hearing form and add one to it to get an autonumber one
value higher than the highest CaseID in the Rulings table and then
assign it to the CaseID of that particular new Hearing. But I'm not
sure if the Max function can do that.

My query for the Hearing form retrieves info like: CaseID,
DateReceived, DecisionDate, etc.. The Ruling form retrieves similar
types of data, but there are some differences. That's why I split the
one original table, generically called "Case" into two separate
tables. One for just Hearings, one for just Rulings. I guess this was
a good idea. Anyway, the CaseID field for both tables is an
autonumber. Since there are more Hearings, the autonumber for the
Hearings table is higher, ui.e. 255. The last Ruling was like 250. So
the next 5 and on Rulings are going to be 251, 252, 253, 254, 255,
256, etc... So the same numbers are going to be used for Hearings and
Rulings.

What I'm thinking about doing is somehow (no idea yet) of comparing
the highest/ biggest CaseID autonumbers from both tables, then adding
one to it to get one number higher, then assigning whatever Hearing or
Ruling is being entered into the database that number. The queries for
both Hearings and Rulings retrieves the CaseID from their associated
queries. The data entry and data view forms are identical. The CaseIDs
are bound. Can I set a bound field equal to another field?

For example, I put a text box that retrieves the highest autonumber
from the table then adds one to it. Let's call this text box,
NewValue. Can I set the bound CaseID equal to this?

NewValue = Max([CaseID])

CaseID = NewValue and still be bound to the associated field in thed
query that retrieves CaseID from both the Hearings and Rulings tables?

But this leads me to another problem. I might have to run some kind of
query that compares the autonumbers from both tables, then returns
only the autonumber from the table that has the biggest value. Then
add one to it. Then assign it to CaseID somehow.

Does any of this make sense? It's late, and I'm beat.

Any suggestions will be a Welcome suprise!

G'Night! Thanks!

Megan
Nov 13 '05 #1
2 2257
On 9 Aug 2004 20:54:31 -0700, me**************@hotmail.com (Megan)
wrote:

As has been argued here many times: you should NOT assign meaning to
autonumbers. They are unique numbers; period. This page:
http://www.mvps.org/access/general/gen0025.htm makes the same point,
but one day I'm going to be mad enough to put up a more detailed page
of my own :=)

When you say: "I don't want both tables to have the same autonumber"
you are attaching too much meaning.

Rather think about some sort of meaningful linkage. A ruling follows a
hearing. Perhaps it makes sense to have a HearingID in the Ruling
table, so you could easily establish which hearing led to which
ruling.

-Tom.

Hi everybody-

I have 2 tables, Hearings and Rulings. Both have primary keys called,
CaseID, that are autonumbers. I don't want both tables to have the
same autonumber. For example, if Hearings has 55, then I want Rulings
to have a number greater than 55. Two or more Hearings may be entered
before a Ruling is entered. For example, Hearings with CaseIDs= 55,
56, and 57 may be entered before a Ruling or vice versa. There is no
definite order. Hearings and Rulings can be entered at any time, in
any order. It all depends on when the users enter the Hearing and/ or
Ruling information.

I can get the maximum number by using the "Max" function. Right now on
the Hearings form, I use the Max function to get the highest/ biggest
autonumber for the Hearings table, i.e. Max([CaseID]). I tried using
the DMax function: DMax(expression, domain, criteria) but it didn't
work for me. Maybe I used it wrong because I didn't enter any criteria
because I'm unsure what criteria to use. But Access Help states that
the criteria is optional. I tried DMax([CaseID], Hearings table) but
it just returned the first/ lowest record number.

Anyway, I was thinking about using the Max function in a hidden text
box on the Hearing form and add one to it to get an autonumber one
value higher than the highest CaseID in the Rulings table and then
assign it to the CaseID of that particular new Hearing. But I'm not
sure if the Max function can do that.

My query for the Hearing form retrieves info like: CaseID,
DateReceived, DecisionDate, etc.. The Ruling form retrieves similar
types of data, but there are some differences. That's why I split the
one original table, generically called "Case" into two separate
tables. One for just Hearings, one for just Rulings. I guess this was
a good idea. Anyway, the CaseID field for both tables is an
autonumber. Since there are more Hearings, the autonumber for the
Hearings table is higher, ui.e. 255. The last Ruling was like 250. So
the next 5 and on Rulings are going to be 251, 252, 253, 254, 255,
256, etc... So the same numbers are going to be used for Hearings and
Rulings.

What I'm thinking about doing is somehow (no idea yet) of comparing
the highest/ biggest CaseID autonumbers from both tables, then adding
one to it to get one number higher, then assigning whatever Hearing or
Ruling is being entered into the database that number. The queries for
both Hearings and Rulings retrieves the CaseID from their associated
queries. The data entry and data view forms are identical. The CaseIDs
are bound. Can I set a bound field equal to another field?

For example, I put a text box that retrieves the highest autonumber
from the table then adds one to it. Let's call this text box,
NewValue. Can I set the bound CaseID equal to this?

NewValue = Max([CaseID])

CaseID = NewValue and still be bound to the associated field in thed
query that retrieves CaseID from both the Hearings and Rulings tables?

But this leads me to another problem. I might have to run some kind of
query that compares the autonumbers from both tables, then returns
only the autonumber from the table that has the biggest value. Then
add one to it. Then assign it to CaseID somehow.

Does any of this make sense? It's late, and I'm beat.

Any suggestions will be a Welcome suprise!

G'Night! Thanks!

Megan


Nov 13 '05 #2
I agree with Tom's point about "meaningless" autonumbers -- that's the
best approach. However, if you are intent on exposing the autonumbers
to the users, a different database structure may accomplish your
goals.

Create a new table with a single, autonumber field called CaseID.
Change the field type of the two, existing CaseID fields to
LongInteger, and Index the fields without duplicates. In the Relation
windows, relate both of the existing tables to the new caseID table.
You have now created two One-to-One relationships. Base all your input
forms on queries that include CaseID table plus one of the other
tables.

When you create a new record in CaseID and begin to populate fields in
the subordinate tables, a matching CaseID value will be placed into
the subordinate tables automatically.

On Mon, 09 Aug 2004 22:21:57 -0700, Tom van Stiphout
<no*************@cox.net> wrote:
On 9 Aug 2004 20:54:31 -0700, me**************@hotmail.com (Megan)
wrote:

As has been argued here many times: you should NOT assign meaning to
autonumbers. They are unique numbers; period. This page:
http://www.mvps.org/access/general/gen0025.htm makes the same point,
but one day I'm going to be mad enough to put up a more detailed page
of my own :=)

When you say: "I don't want both tables to have the same autonumber"
you are attaching too much meaning.

Rather think about some sort of meaningful linkage. A ruling follows a
hearing. Perhaps it makes sense to have a HearingID in the Ruling
table, so you could easily establish which hearing led to which
ruling.

-Tom.

Hi everybody-

I have 2 tables, Hearings and Rulings. Both have primary keys called,
CaseID, that are autonumbers. I don't want both tables to have the
same autonumber. For example, if Hearings has 55, then I want Rulings
to have a number greater than 55. Two or more Hearings may be entered
before a Ruling is entered. For example, Hearings with CaseIDs= 55,
56, and 57 may be entered before a Ruling or vice versa. There is no
definite order. Hearings and Rulings can be entered at any time, in
any order. It all depends on when the users enter the Hearing and/ or
Ruling information.

I can get the maximum number by using the "Max" function. Right now on
the Hearings form, I use the Max function to get the highest/ biggest
autonumber for the Hearings table, i.e. Max([CaseID]). I tried using
the DMax function: DMax(expression, domain, criteria) but it didn't
work for me. Maybe I used it wrong because I didn't enter any criteria
because I'm unsure what criteria to use. But Access Help states that
the criteria is optional. I tried DMax([CaseID], Hearings table) but
it just returned the first/ lowest record number.

Anyway, I was thinking about using the Max function in a hidden text
box on the Hearing form and add one to it to get an autonumber one
value higher than the highest CaseID in the Rulings table and then
assign it to the CaseID of that particular new Hearing. But I'm not
sure if the Max function can do that.

My query for the Hearing form retrieves info like: CaseID,
DateReceived, DecisionDate, etc.. The Ruling form retrieves similar
types of data, but there are some differences. That's why I split the
one original table, generically called "Case" into two separate
tables. One for just Hearings, one for just Rulings. I guess this was
a good idea. Anyway, the CaseID field for both tables is an
autonumber. Since there are more Hearings, the autonumber for the
Hearings table is higher, ui.e. 255. The last Ruling was like 250. So
the next 5 and on Rulings are going to be 251, 252, 253, 254, 255,
256, etc... So the same numbers are going to be used for Hearings and
Rulings.

What I'm thinking about doing is somehow (no idea yet) of comparing
the highest/ biggest CaseID autonumbers from both tables, then adding
one to it to get one number higher, then assigning whatever Hearing or
Ruling is being entered into the database that number. The queries for
both Hearings and Rulings retrieves the CaseID from their associated
queries. The data entry and data view forms are identical. The CaseIDs
are bound. Can I set a bound field equal to another field?

For example, I put a text box that retrieves the highest autonumber
from the table then adds one to it. Let's call this text box,
NewValue. Can I set the bound CaseID equal to this?

NewValue = Max([CaseID])

CaseID = NewValue and still be bound to the associated field in thed
query that retrieves CaseID from both the Hearings and Rulings tables?

But this leads me to another problem. I might have to run some kind of
query that compares the autonumbers from both tables, then returns
only the autonumber from the table that has the biggest value. Then
add one to it. Then assign it to CaseID somehow.

Does any of this make sense? It's late, and I'm beat.

Any suggestions will be a Welcome suprise!

G'Night! Thanks!

Megan

**********************
ja**************@telusTELUS.net
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security
Nov 13 '05 #3

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

Similar topics

4
by: Matt | last post by:
I posted this problem before but no reply. Now I repost again. I want to compare the address number in javascript, and the address number is alphanumeric. I have a text box and the user needs to...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
8
by: MLH | last post by:
Anybody's solution would be appreciated. Pls, do not pause to write anything for this. I'm not looking for that kind of a handout. I have an idea about how to do it, but I wanted to see if anyone...
18
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
2
by: clickon | last post by:
I am using ASP.net 2.0 and trying to take advantage of the updated data editing facilities provided through the SQLDataSource control and the DetailsView control. The data is a record from a...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
3
by: kathnicole | last post by:
Hi, I am using MS Access 2007/Vista I have a field, ProductCost in the subform. i need to find the total of ProductCost and assign it to a field, Total, in the Main Form . I read an article...
4
by: Greg (codepug | last post by:
Private Sub cboBody_KeyDown(KeyCode As Integer, SHIFT As Integer) 'Delete combobox entry if Del or Backspace key is hit. If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = "" End Sub I have...
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?
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
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
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...
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,...
0
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...

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.