I'm sure there's lots of ways to do this. Here's one idea. Create a table with in SQL with an autoincrement column and a column to insert the users userid, [IDTable], so when the form opens you have the incremented value and its association to the user. When you save the form, save all of the data on the form to a second table [Requests]. The Requests table will have a column for the SubmissionID and a column to mark the resubmissions, Resubmissions, making both the SubmissionID and Resubmissions columns ints.
How many resubmissions are you allowed? The alphabet only has 26 letters and you could possibly run out. Whether there is a finite number of submissions or not you could build an alphabet table with an AlphaID column, int (increment). Make an entry with the ID of 0 with nothing in the Alphabet column before turning on autoincrement. That way on the first submission INSERT in the Requests table the AlphaID column will be 0. Successive submissions will find the matching row for the SubmissionID column. If you get a hit then you know this is a resubmit. Then you can add one (1) to the AlphaID column and insert the second (?) resubmission. When you display the reference number you can cast the SubmissionID as a varchar and concatenate the Alphabet column from the Alphabet table.
Hope this helps.
Richard
|