Skip to main content

Notifications

Microsoft Dynamics GP forum
Unanswered

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

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

*******

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

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,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Product updates

Dynamics 365 release plans