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

liamfitz

Registered User.
Local time
Today, 11:07
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.
 
When the combo is in its unexpanded state, it shows only the first visible column of its RowSource. If you want it to show more, you need to concatenate some columns.

Select StudentID, FirstName & " " & LastName As FullName,...
From ...

Assuming that StudentID is the PK and is hidden as is normal with combos, the first visible column should be FullName.

Access help is unhelpful in most cases with regard to event firing order so when I need to work out what is going on, I put message boxes in various events and so I can see the order in which they get executed as the message boxes pop up.

When working with textboxs, combos, and listboxes on a form, the most commonly used events are BeforeUpdate and AfterUpdate. We would need to know what you are trying to do to suggest the appropriate event.
 
In Access Help search

"Order of events for database objects"
 
I'm not sure what version of Access you are using Rain but that search results in nothing useful in A2010.

You can look at the events for each object if you know how to navigate the the Developer Reference section of help but that doesn't identify the order in which events fire.

Help in older versions of Access did attempt to define event order in limited situations but I'm not sure there is a reasonable way of documenting event order because so much depends on what you actually do.

A long time ago (maybe as far back as A97) Microsoft or some kind soul actually created a sample database that included an event logger. It included debug code in every event and wrote a line to the debug window which could then be examined.

If anyone has the database handy, please post it. I'll look also.
 

Attachments

  • A2010Help.jpg
    A2010Help.jpg
    94.1 KB · Views: 237
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