hi i have a simple problem i am creating purchase order form in vb.. i want to show incrementd value to user in text field every time user creates new order.....storing this in data base is not a problem for me but the problem is how i auto increment at run time and even program is re-compiled its value does not reset to 0.

Does user perform an action to say they want to create a new record and when they perform this action you clear all fields except this new order number in preparation for user to enter data? Then...

Text1.Text = Trim(Rs.Fields("IDField").Value + 1)

(Note: In multi user environment this can become such a pain that it is not worth this kind of code.)

Or does this new number appear somewhere after the new record is added? Then...

strSQL = "UPDATE MyTable SET MyField = [MyTable].[MyField]+1"
Cn.Execute strSQL

(Note: Prefered way.)

Good Luck

thanks for your reply....
yes user desire to create new shipping receipt...i have auto incremented value receiptID in SQL server database...i have placed a text box field on form that get value of new row in database mean receipt id...but i am using Adodc.recordset.addnew which clear all text fields when form is open...i want that it clear all fields but except receiptID.text field...if you have solution for this it will solve my problem. waitnig for your help...

Well from the sounds of it if you really want the user to view and/or to be able to modify the receiptID then you are going to need another field. Your autonumber field should only be used for keeping the uniqueness of the record. If you still want to display this field then lock the user from being able to modify it, else you will recieve errors if the user does try to insert their own number into your autonumber field.


Good Luck

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.