OK so thank you for the above here is the code at the moment, BUT still an issue.
So the issue is it still not doing what my original post stated. Just to be clear.
Example: I click to select supervisor, I select for example SUKDEO and then I select BISSO. SUKDEO is the primary supervisor for that job (which in turn I need ONLY his gang number to populate). BUT with this code, when I select SUKDEO and then I select BISSO, Bissos gang number is the one that populates not the (back to my OP) FIRST SELECTED or (maybe I should have said primary) SUPERVISOR.
CORRECTION: the issue only happens with the NEXT supervisor. IF I select every other supervisor the code works. please see pic.
Hope that makes scene, here is the code and here is a pic.
does not work with next supervisor
only works with every other supervisor
Private Sub SUPERVISOR_AfterUpdate()
Dim supe1Data As String
Dim va As Variant
va = Me.SUPERVISOR.Value '* Multi-valued Field (MVF)
Debug.Print "==============================="
If IsNull(va) Then
'Value is NULL if NO MVF list items are selected
supe1Data = ""
Else
'* A Multi-valued Field (MVF) ComboBox will
'* return a variant array of variants. The
'* array-element variants will be of a type
'* that is compatible with the underlying field value.
'*** Question-specific code ***
Dim iLower As Integer
Dim iUpper As Integer
iLower = LBound(va)
iUpper = UBound(va)
'* Get first selected supervisor code
If iUpper = 0 Then
'* Only ONE value selected, so
'* .Column(2) contains valid data
'* .Recordset property is NOTHING
'* Contrary to online docs, for MVF...
'* Column(0) is bound data value
'* Column(i) is column i from 1 to .ColumnCount
supe1Data = Me.SUPERVISOR.Column(2)
Else
'* MULTIPLE value selected, so
'* .Column(2) is NULL
'* .Recordset property is valid and open
Dim rs As Recordset2
Set rs = Me.SUPERVISOR.Recordset.Clone
'* Since data is already available, lookup can be
'* more efficient than new query (i.e. using DLookup)
rs.FindFirst "[LAST NAME] = '" & va(0) & "'"
If Not rs.NoMatch Then
'* Here, column indices start at 0
supe1Data = rs.Fields(1).Value 'Second column
Else
supe1Data = "ERROR" 'Unexpected
End If
rs.Close
End If
End If
Me.WORK_ID = Right(supe1Data, 3) & Format(Me.RECEIVED_DATE, "yymmdd")
End Sub
I think that's as clear as I can get lol thank you guys once more, looks like we are almost there :)
-S