Bug in combobox

diasflac

Registered User.
Local time
Today, 13:51
Joined
May 13, 2013
Messages
45
I have a combobox on a form linked to a table. The format of the column in the table is Yes/No. The form which inputs into the table is also set to Yes/No.

However of the form below, even though the combobox is set to Yes/No, when you open the box it displays as -1 for yes and 0 for no.

How has this happened?
 
You are saying that you have a table with check boxes set to yes/no.
You are using these check boxes in a combo box.
These yes/no check boxes are showing as -1 and 0 in the combo box.

When I make a combo box with yes/no check boxes my combo box shows yes/no.

Dale
 
You are saying that you have a table with check boxes set to yes/no.
You are using these check boxes in a combo box.
These yes/no check boxes are showing as -1 and 0 in the combo box.

When I make a combo box with yes/no check boxes my combo box shows yes/no.

Dale

The first form which inputs into the table also displays as Yes/No, the form which filters and displays results in a subform shows as -1 and 0. I'll attach a screenshot.
 

Attachments

  • Binary.jpg
    Binary.jpg
    86.8 KB · Views: 139
Try replacing the combo. Sometimes objects get corrupted.
 
When replacing the combo, try an option group.
 
I deleted it and recreated. It was displaying yes/no up until I added the tag so it can filter the subform. I'll paste the code, is there anything in here which causes the type to change from Yes/No?

Code:
Option Compare Database
Option Explicit

Private m_colCombos As Collection
Private m_strFilter As String

Private Sub ApplyFilter(Optional ByVal Filter As String)

    If Len(Filter) > 0 Then
        FindRFQsubform.Form.Filter = Filter
        FindRFQsubform.Form.FilterOn = True
    Else
        FindRFQsubform.Form.Filter = ""
        FindRFQsubform.Form.FilterOn = False
    End If
    
End Sub

Private Function BuildFilter()

    Const c_LinkOperator As String = " AND "
    
    Dim ctl As Control
    Dim m_strFilter As String
    Dim strCriteria As String
    
    m_strFilter = ""
    For Each ctl In m_colCombos
        If Not IsNull(ctl.Value) Then
            If Len(m_strFilter) > 0 Then m_strFilter = m_strFilter & c_LinkOperator
            strCriteria = ctl.Tag & " Like " & GetQuotedValue(ctl.Tag, ctl.Value)
            m_strFilter = m_strFilter & strCriteria
        End If
    Next ctl
    ApplyFilter m_strFilter
    
End Function

Private Function GetQuotedValue(ByVal FieldName As String, ByVal Value As Variant) As String

    Select Case FindRFQsubform.Form.RecordsetClone.Fields(FieldName).Type
        Case dbMemo, dbText
            GetQuotedValue = "'" & Value & "'"
        Case dbDate, dbTime
            GetQuotedValue = "#" & Format(Value, "mm/dd/yyyy hh:nn:ss") & "#"
        Case Else
            GetQuotedValue = Value
    End Select
    
End Function

Private Sub InitializeComboCollection()

    Const c_SQL As String = "SELECT DISTINCT NULL FROM @T UNION SELECT DISTINCT @C FROM @T;"
    Dim ctl As Control
    
    Set m_colCombos = New Collection
    For Each ctl In Me.Controls
        If ctl.ControlType = acComboBox Then
        If ctl.HelpContextId = -4 Then
            ctl.RowSource = Replace(Replace(c_SQL, "@T", "FindRFQ"), "@C", ctl.Tag)
            ctl.AfterUpdate = "=BuildFilter()"
            m_colCombos.Add ctl
        End If
        End If
    Next ctl

End Sub

Private Sub Form_Open(Cancel As Integer)

    InitializeComboCollection
    
End Sub
 
I don't understand SQL code, but I understand that you change the Row Source for your combo box when you run this code.
So, I'm pretty sure that the new query behind your combo box control don't fit the combo's columns order, or even the number.

Sorry if I'm wrong
 
Everything appears to be correct, I've set everything up again, including the query. Still 0 and -1
 

Users who are viewing this thread

Back
Top Bottom