Which event triggers when value is selected from a Combo Box ?

liamfitz

Registered User.
Local time
Today, 17:17
Joined
May 17, 2012
Messages
240
Could anyone tell me which event is triggered, on selecting a value from a Combo Box ( and if possible, why in a list taken from two fields Forename and Surname, when a name is selected, it only shows the forename ) ? Many thanks in advance.:confused:
 
The Events are the Same as any other control. Best search Access Help for full details.

Re What's showing and what isn't. This depends on how it is set up in the Properties of the Control. (Column Widths) However only one field will end up showing. You can add a second text box for the other Field or you could Concatenate them in your query.
 
Many thanks. I'll look into it.
 
In Access Help search

"Order of events for database objects"
 
I've got somewhere now, ( I've set the combo's Row Source Property to 'Value list' and loaded a concatenated string to the Rowsource, pulling data from the relevant fields in a recordset, using a loop to move through the RS ) It works perfectly. Got the full name, and perfect for comparison of Combo's value against fields. Thanks.

Here's the code. someone might find it useful, obviously changing field names etc. as appropriate.
---------------------
Private Sub Form_Load()
strFullpath = CurrentDb.Name
Set db = OpenDatabase(strFullpath)
Set rs = db.OpenRecordset("SELECT Forename, Surname FROM tblAdvocates")
If Not (rs.EOF And rs.BOF) Then
rs.MoveLast
c = rs.RecordCount - 1
Dim strName As String
rs.MoveFirst
For i = 0 To c
If i = 0 Then
strName = rs.Fields("Forename") & " " & rs.Fields("Surname")
Else
strName = strName & ";" & rs.Fields("Forename") & " " & rs.Fields("Surname")
End If
rs.MoveNext
Next i
Me.cboSelectUser.RowSource = strName
End If
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
txtPIN.SetFocus
txtPIN.Text = ""
End Sub

-----------------------
N.B. Note the clever use of the ";" separators fro the list items loaded to the ComboBox ( cboSelectUser in this case ) ... Thanks for your interest.
 

Users who are viewing this thread

Back
Top Bottom