Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

VB code Customer

(0) ShareShare
ReportReport
Posted on by 555

Hi,

My requirement is  ,In customer maintenance screen i want to add a  button ,if i press the button then ,In customer Id field will display the maximum custid+1.

Example in customer table max id is 23 then result will be "000000024"

it's very urgent please can any one help me?...

My code is 

Private Sub Button1_Click()

Dim Sqlstmt As String
Dim lsNexCustid As String
Dim liNexCustid As Long

Sqlstmt = "Select Top 1 * from customer order by custid desc"

err_Customer = sqlfetch_Customer1(Sqlstmt)

If err_Customer = NOTFOUND Then
NextCustid = "000000001"
Else
liNexCustid = CLng(bxCustomer.CustId) '"000000001" '
liNexCustid = liNexCustid + 1
lsNexCustid = Format(liNexCustid, "000000000")
End If

Call SetBufferValue("bcustomer.custid", lsNexCustid)
Call DispFields("form1", "ccustid")

Call Edit_Save

End Sub


Public csr_Customer As Integer
Public err_Customer As Integer

In here i got  sqlfetch_Customer =0 only...

Function sqlfetch_Customer(Sqlstmt As String) As Integer
sqlfetch_Customer = SqlFetch1(csr_Customer, Sqlstmt, bCustomer, LenB(bCustomer))
End Function

i am also adding Customer Dh files.

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Featured topics

Product updates

Dynamics 365 release plans