Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

VBA code causing record not able to show saved details if retrived using lookup button

(0) ShareShare
ReportReport
Posted on by 190

I have VBA code in Assembly Entry windows that will set the user defined field 1 of Assembly Document Detail Entry windows to a value based on the Document Number. The code works fine.

Problem is that if user use Document Number lookup to retrieve a record, it will NOT display the saved details. But if the document number is entered manually or moved using the next/prior record button, it works OK.

Can someone help look at what I did wrong?

thanks in advance.

below my VBA code:

*************

Dim xDOCNUMBER As String

Private Sub DocumentNumber_Changed()

If Me.DocumentNumber <> "" Then

If xDOCNUMBER <> Me.DocumentNumber Then

Dim xUSR1string As String, xUSR1pos As Integer

xUSR1pos = InStr(1, Me.DocumentNumber, "-")

If xUSR1pos >= 2 Then

xUSR1string = Trim(Left(Me.DocumentNumber, xUSR1pos - 1))

Else

xUSR1string = Trim(Me.DocumentNumber)

End If
Me.ExpansionButton1 = 1
If AssemblyDocumentDetailEntry.UserDefined1 <> Trim(xUSR1string) Then

AssemblyDocumentDetailEntry.UserDefined1 = Trim(xUSR1string)

End If

AssemblyDocumentDetailEntry.OK = 1
Me.Changed = False

End If

End If

End Sub

Private Sub Save_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)

xDOCNUMBER = Me.DocumentNumber

End Sub

*******

*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

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans