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
*******
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,524 Super User 2024 Season 2
Martin Dráb 228,493 Most Valuable Professional
nmaenpaa 101,148