Hi, Tim.
Thank you for your help. Sorry about the ID field. Actually, it is a field
with the value of StudenID that has 5 characters in length, i.e., 21032. I
can not use AutoNum for this field. How can I code this programmatically?
Well, it depends upon how you want this five character value designed. Is
it to be incremented by one each time a new record is created? Does it
require leading zeros? Is there a floor and ceiling for this number? Will
it ever have non-digits? Et cetera.
A very simple method of incrementing a field by one is to use the DMax( )
function to find the highest number in a field and add one to that number.
If you need to format that value with leading zeros, then try:
Me!txtStudentID.Value = Format((Nz(DMax("StudenID", "tblStudents"), 0) +
1), "00000")
.... where txtStudentID is the name of the text box displaying the StudenID
field, and tblStudents is the name of the table where the StudenID field is
located.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.