Skip to main content

Notifications

Microsoft Dynamics SL forum
Unanswered

VB code Customer

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.

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

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans