Hello there guys!

Need you expertise run time error: '91': Object Variable or with block variable not set. I got the syntax in Do while not .EOF statement. Thanks in advance!

Private Sub Form_Load()

With adVideos.Recordset

    cmbCategory.Clear
    
    Dim i As Integer
    Dim st As String
    Dim b As Boolean
    
    cmbCategory.AddItem "All"
    
    Do While Not .EOF
    
        st = .Fields!Category
        b = False
        
        For i = 0 To cmbCategory.ListCount - 1
        
            If st = cmbCategory.List(i) Then
            b = True
        End If
    Next
    
        If b = False Then
            cmbCategory.AddItem st
        End If
        
    .MoveNext
    
    Loop
    
End With

If cmbCategory.ListCount > 0 Then

    cmbCategory.ListIndex = 0
Else

    cmbCategory.ListIndex = -1
End If

cmdLend.Visible = False
cmdReserve.Visible = False

LoadRecs

End Sub

It maybe causing by Null return value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.