Forum Moderators: open

Message Too Old, No Replies

Creating an order number

Selecting the first 3 characters of a table field or form text field

         

wingnut

5:13 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



I need to create an order number from either a table field or passed form text field value where the number of characters will exceed 3. The order number will be made up of sets of 3 charcters/numbers.

For instance if there was a passed value from a text field called 'Name', I need to be able to select the first 3 characters of this.

TIA

wingnut

5:16 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



Forgot to say I am using ASP with VB Script :)

mattglet

5:26 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From what I gather, you're looking for the Left() Function [devguru.com]. Am I right?

aspdaddy

5:26 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can test the length of a string with the vbscript len function and select the first 3 characters with the left function.

if len(request.form("txtName"))>3 then
strName = left(request.form("txtName"),3)
end if

wingnut

5:45 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



Thx I'll give your suggestions a go.

Easy_Coder

12:58 am on Jun 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is just a suggestion... in addition to your order number creation mechanism.

Consider using a composite key on the database table to avoid collisions that can potentially occur when building an order number using this method.

An int identity row with auto-increment coupled with your order number would create a unique composite key that would not have collission issues.

wingnut

8:54 am on Jun 12, 2005 (gmt 0)

10+ Year Member



Yes thanks Easy_Coder, the last 3 digits will be made from the record ID + a seed mumber.