cheuschober
Muse of Fire
- Local time
- Yesterday, 21:32
- Joined
- Oct 25, 2004
- Messages
- 168
So I used the last hour or so looking for a similar query to no avail.
Thought I'd throw this to the wolves as I keep stumping myself somewhere around the DMax().
Basically we're converting an old 97 database with very bad keys and no naming system to a newly modeled 2000 db. In our old system we have a table [Table1] with a 3 field key [Year] [Site] [Class]. Because multiple entries of the same class can happen within the same site and the same year this has caused nothing but headaches. In the new model the key is [Year] [Site] [ClassID] where [ClassID] is an incremented byte that (I'm assuming) our data entry people will fill in by hand. The issue is transferring the 20 000 records or so over.
They (being the powers that be) want [classID] to reset to 1 with each [year] and [site].
So what I have gleaned thus far is that I should be able to use DMax()+1 to increment the field however I can't seem to find the correct argument as to just -what- is being DMax'ed. Since this isn't a form but a query that I'll eventually turn into an update I can't reference the control.
Of course the second part of the question is how I'm supposed to tell it to reset the count at each combination of [year] and [site] but I'm willing to sniff around a little longer on that one--would I be wrong to say the answer is to be found in the For... Each... Next???
Thanks,
~Chad
Edit: It should be noted that [year] and [site] are non-sequential numeric fields but [class] is a 3 character text field
Thought I'd throw this to the wolves as I keep stumping myself somewhere around the DMax().
Basically we're converting an old 97 database with very bad keys and no naming system to a newly modeled 2000 db. In our old system we have a table [Table1] with a 3 field key [Year] [Site] [Class]. Because multiple entries of the same class can happen within the same site and the same year this has caused nothing but headaches. In the new model the key is [Year] [Site] [ClassID] where [ClassID] is an incremented byte that (I'm assuming) our data entry people will fill in by hand. The issue is transferring the 20 000 records or so over.
They (being the powers that be) want [classID] to reset to 1 with each [year] and [site].
So what I have gleaned thus far is that I should be able to use DMax()+1 to increment the field however I can't seem to find the correct argument as to just -what- is being DMax'ed. Since this isn't a form but a query that I'll eventually turn into an update I can't reference the control.
Of course the second part of the question is how I'm supposed to tell it to reset the count at each combination of [year] and [site] but I'm willing to sniff around a little longer on that one--would I be wrong to say the answer is to be found in the For... Each... Next???
Thanks,
~Chad
Edit: It should be noted that [year] and [site] are non-sequential numeric fields but [class] is a 3 character text field
Last edited: