J
Jenn Civello
I have a form, that has an autonumber in it and when I go to the next record
the autonumber field does not automatically updated.
the autonumber field does not automatically updated.
I have a form, that has an autonumber in it and when I go to the next record
the autonumber field does not automatically updated.
Yes I am, but this is what I am trying to do.
I have a query with 4 fields. The first field has "ITCC", the second field
has "07" and the third field is an autonumber field and the fourth field is
Change Control Number: [Field1] & [Field2] & "-" & [Field3], this is suppose
to bring everything together so it looks like, ITCC07-21. It shows up like
this if I enter the information into the table first, but I don't want to
enter it into the table, I want to have a form that users can use to enter
in the information. When I enter information into on of the other fields the
number just shows up like "-21", but I want the "ITCC" in front of the
number. Is there any way that I can make this happen?
John Vinson said:Yes I am, but this is what I am trying to do.
I have a query with 4 fields. The first field has "ITCC", the second
field
has "07" and the third field is an autonumber field and the fourth field
is
Change Control Number: [Field1] & [Field2] & "-" & [Field3], this is
suppose
to bring everything together so it looks like, ITCC07-21. It shows up
like
this if I enter the information into the table first, but I don't want to
enter it into the table, I want to have a form that users can use to enter
in the information. When I enter information into on of the other fields
the
number just shows up like "-21", but I want the "ITCC" in front of the
number. Is there any way that I can make this happen?
This is a bad idea for two or three reasons.
For one, you're misusing autonumber. Autonumbers will NOT start over
in 2008 (if the 07 is in fact referring to 2007); you're creating an
"intelligent key" - not a compliment, it means that you're trying to
store information in a key; it's redundnant; the field is non-atomic.
The only justification for this composite field is for compatibility
with a long-established paper system. If you do need to do that, then
I'd store it in two fields - a date or year field (the 07 component)
and an Integer or Long Integer field (*not* an Autonumber). You would
use code to increment the number, starting over on January 1 each year
if that's what you want to do; and combine the fields *at the time you
need to display them*, rather than storing this composite redundant
field.
John Vinson said:Yes I am, but this is what I am trying to do.
I have a query with 4 fields. The first field has "ITCC", the second
field
has "07" and the third field is an autonumber field and the fourth field
is
Change Control Number: [Field1] & [Field2] & "-" & [Field3], this is
suppose
to bring everything together so it looks like, ITCC07-21. It shows up
like
this if I enter the information into the table first, but I don't want to
enter it into the table, I want to have a form that users can use to enter
in the information. When I enter information into on of the other fields
the
number just shows up like "-21", but I want the "ITCC" in front of the
number. Is there any way that I can make this happen?
This is a bad idea for two or three reasons.
For one, you're misusing autonumber. Autonumbers will NOT start over
in 2008 (if the 07 is in fact referring to 2007); you're creating an
"intelligent key" - not a compliment, it means that you're trying to
store information in a key; it's redundnant; the field is non-atomic.
The only justification for this composite field is for compatibility
with a long-established paper system. If you do need to do that, then
I'd store it in two fields - a date or year field (the 07 component)
and an Integer or Long Integer field (*not* an Autonumber). You would
use code to increment the number, starting over on January 1 each year
if that's what you want to do; and combine the fields *at the time you
need to display them*, rather than storing this composite redundant
field.
John W. Vinson[MVP]
Is code hard to do? I am not a very advanced user, that's why I was trying
to get around it by using an auto number field.
How would I go about using code to increment the number?
John,
Yes this is a mutil user database, and there might be several users updating
and adding new records to the database at one time.
What if I changed this database to be a single user database, could you give
me any suggestions?
John W. Vinson said:What if I changed this database to be a single user database, could you
give
me any suggestions?
Sure... but that would be a pretty drastic change! If it's a multiuser
database because you want multiple users to USE it, you certainly
wouldn't want to remove that capability just to save a bit of coding!
What's the real-world situation? Will there routinely be two or more
users attempting to create new records at the same time, or is that
just not something that will happen (because of staff assignments and
the actual work-room processes)?
The simplest way to increment the number for the "only one user will
be inserting records" scenario would use the Form's Beforeinsert
event, with code like
Private Sub Form_BeforeInsert(Cancel as Integer)
Me.txtSeqNo = NZ(DMax("[SeqNo]", "[yourtablename]")) + 1
End Sub
This will find the maximum existing SeqNo value in the table named
yourtablename, increment it by one, and store it in the (bound)
textbox named txtSeqNo. The risk (in multiuser applications) is that
another user might get the same number if they enter a record while
the first user still has this record on the form, not committed to
disk.
John W. Vinson [MVP]
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.