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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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 202

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans