Kiran Angara
2017-08-30T06:34:25Z
How to avoid the application crash and show to only empty dropdown if the recordset supplied to the cell combo is empty.
Igor/10Tec
2017-08-30T08:51:12Z
It's not a suggestion, it's a bug - so I moved your post to the "Questions and Issues" section.

Can you tell us how to reproduce this problem? Perhaps, you can also send us a sample to reproduce this.
Kiran Angara
2017-09-05T01:07:32Z
Originally Posted by: Igor/10Tec 

It's not a suggestion, it's a bug - so I moved your post to the "Questions and Issues" section.

Can you tell us how to reproduce this problem? Perhaps, you can also send us a sample to reproduce this.



  iGridCombo 1.1.rar (24kb) downloaded 40 time(s).

Apologies for posting in wrong section.

I upload the sample for your kind perusal please go through it and do the needful.

Try to open Equipment/Defect Category column combo, it will show a run time error or application crashes.
Igor/10Tec
2017-09-05T14:12:10Z
Thank you for the project. It really helped to understand why this crash occurs. In two words, the problem occurs as you refer a combo box that does not exist.

See, you define the columns in which the problem occurs using the following code in the PopulateGridLayout sub:

With .AddCol(sKey:=vGridFields(iGrd, i, 3), sHeader:=vGridFields(iGrd, i, 1), lWidth:=vGridFields(iGrd, i, 2), eHeaderAlignH:=vGridFields(iGrd, i, 10))
	.eType = igCellCombo
	.sCtrlKey = vGridFields(iGrd, i, 3)
	.eAlignH = vGridFields(iGrd, i, 10)
End With

You expect that the combos you are going to use in the columns are created in the g_pSetComboItemValue sub:

Public Sub g_pSetComboItemValue(ByVal iGrd As Integer, ByVal sSQL As String, ByVal vTextField As Variant, ByVal vValueField As Variant)
On Error Resume Next
    Dim rsFillCombo As ADODB.Recordset
    Dim cboGrid As ComboObject ' An iGrid combo list

    Set rsFillCombo = New ADODB.Recordset
    If rsFillCombo.State = 1 Then rsFillCombo.Close
    rsFillCombo.Open sSQL, gConnectDB, adOpenForwardOnly, adLockReadOnly
    If Not rsFillCombo.EOF Then
        With iGridName(iGrd)
            .BeginUpdate
                Set cboGrid = .Combos.Add(vValueField)
                cboGrid.FillFromRS rsFillCombo, vTextField, vValueField
                cboGrid.AutoAdjustWidth
           .EndUpdate
        End With
    End If
    Set rsFillCombo = Nothing
    
End Sub

However, if the recordset does not contain any records, the combo object is not created too!

To fix the problem, we need to create the combo object in any case - regardless of the number of records in the recordset. I rewrote your g_pSetComboItemValue sub accordingly, and in my version of your project it looks like this:

Public Sub g_pSetComboItemValue(ByVal iGrd As Integer, ByVal sSQL As String, ByVal vTextField As Variant, ByVal vValueField As Variant)
On Error Resume Next
    Dim rsFillCombo As ADODB.Recordset
    Dim cboGrid As ComboObject ' An iGrid combo list

    Set rsFillCombo = New ADODB.Recordset
    If rsFillCombo.State = 1 Then rsFillCombo.Close
    rsFillCombo.Open sSQL, gConnectDB, adOpenForwardOnly, adLockReadOnly
    Set cboGrid = iGridName(iGrd).Combos.Add(vValueField)
    If Not rsFillCombo.EOF Then
        cboGrid.FillFromRS rsFillCombo, vTextField, vValueField
        cboGrid.AutoAdjustWidth
    End If
    Set rsFillCombo = Nothing
    
End Sub

Note that we do not need to call iGrid's BeginUpdate/EndUpdate when we create a combo list and populate it because there are no objects in the iGrid viewport that must be redrawn.
Igor/10Tec
2017-09-28T13:58:25Z
We have released an update for iGrid ActiveX today (v6.5.80). This update contains a special check that eliminates crashes in situations when a combo box cell refers a combo list that was not created.