web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans