Private Sub cbxname_Change()
‘ this procedure fills combo box with Firstname and Surname in that order – management preference - but still ‘finds’ based on surname - separate on click procedure
Dim lastrow As Long, mychoice As Long
Dim fn As String, ln As String, box As String
changed = changed + 1
If authorised ‘Boolean value
Then
Call allowed
‘ allowed procedure is the same except IF loop looking at “withdrawn” status is commnented out to allow all records to be added to combobox
Exit sub
Else
lastrow = Range("Surname", Range("Surname")).Rows.Count
For Each strchoice In Range("surname")
If Cells(strchoice.Row, Range("Type").Column).Text <> "withdrawn" Then
If LCase(Left(strchoice, 1)) = Me.cbxname And Me.cbxname <> "" Then
y = strchoice.Address
x = Range(y).Offset(0, -1).Address
Z = Range(y).Offset(0, -3).Address
fn = Range(x).Text
ln = Range(y).Text
myid = Range(Z).Value
‘ myid is used for fast find in ID# number column
box = fn & " " & ln
Demo.cbxname.AddItem
Demo.cbxname.List(ind, 0) = myid
Demo.cbxname.List(ind, 1) = box
ind = ind + 1
End If
End If
Next
Me.cbxname.DropDown
End Sub