Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Auto Account Generating code

Author  Topic 

TIM007
Starting Member

1 Post

Posted - 2011-02-17 : 05:31:30
hi guys.m trying to create a system that automatically generate customer account. da account must begin with de first three letters of the customer's Last_Name nd end up with da last 5 digits incremented by 1 every time de new customer is added into da system (eg for Smith 'SMI00001',for Smiley 'SMI00002'.nd for Jackson 'JAC00001').i have da code frm da internet nd cnt figure out how to how nd where to put it in my .netASP C# code and SQL.m using SQL server database tables. M NEWBIE

Me.Dirty = False
If Me.NewRecord Then
Dim strWhere As String
Dim varResult As Variant

strWhere = "CUST_ACC_NO Like """ & Left(Me.CUST_NAME, 1) & "*"""
varResult = DMax("CUST_ACC_NO", "tblCusAcc", strWhere)

If IsNull(varResult) Then
Me.CUST_ACC_NO = Left(Me.CUST_NAME, 1) & "-001"
Else
Me.CUST_ACC_NO = Left(varResult, 2) & _
Format(Val(Right(varResult, 3)) + 1, "000")
End If
Me.Refresh
End If

da system must generate da account automatically on ADD_Button click.PLEASE HELP!
   

- Advertisement -