I have an identity (auto-increment) column in my mssql table, which is also my primary key. I want to use these numbers on my form, such that when I open that form, the auto-increment id will already be displayed on a textbox (so I wont have to type it in anymore). It's like, trying to display the next auto-increment id on form load while no data is entered yet. Like on paper forms where the form numbers are already there before it is even used or filled up. I hope I'm making it clear. Is it possible? How do you do that? I really have no idea how to do it.
airhalynn101
0
Light Poster
Recommended Answers
Jump to PostDo you mean that when you bring up a blank form (so you can create a new entry) the ID number of the record that will be added is displayed? The answer depends on whether or not there is only one user hitting the database at a time.
Jump to PostThen you can get the next available ID number by
SELECT nextID=MAX(ID)+1 FROM mytable
Just remember not to specify ID when you save the record or you will get an error.
All 6 Replies
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
airhalynn101
0
Light Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
airhalynn101
0
Light Poster
airhalynn101
0
Light Poster
airhalynn101
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.