ComboBox selection to perform an action (1 Viewer)

5hadow

Member
Local time
Today, 03:15
Joined
Apr 26, 2021
Messages
89
Hello everyone!

I'm having some problems with my combo box selection. I need to select an item from drop-down combo box and depending on the selection perform an action. In this example, a simple message box with yes or no.

Code:
Private Sub cboReview_AfterUpdate()
    DoCmd.Save
    Me.cboReview.Requery
    If Me.cboReview.Selected(intCurrentRow) = 1 Then
        MsgBox ("Yes")
    Else
        MsgBox ("No")
    End If
       
End Sub

Combo box is based on a bound field from a table. It's in value list mode.

Problem is that it reports selection as 0 no matter what. Even if I select item 1, or 2 and so on. I threw in "Save" and "Requery" to see if it'll help. What is going on here?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:15
Joined
Aug 30, 2003
Messages
36,125
Try

If Me.cboReview = 1 Then
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:15
Joined
Oct 29, 2018
Messages
21,467
Hi. Requery will probably reset the selection, so you should take it out. The Selected property is probably a boolean, so try using True or -1. Otherwise, just check the Value of the Combobox.
 

Users who are viewing this thread

Top Bottom