by Issa Fahmy (7 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 16th August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This Function automatically populates standard combo with information typically from database tables when using RDO. You need to pass the
'Return Number of Rows Found : If error, return -1
'Table argument can be a join expression
Dim rs As rdoResultset
Dim intRows As Integer
Dim strSQL As String
On Error GoTo Err_Handler
If ClearList Then cbo.Clear
intRows = 0
If cnvString(CompoundField) <> "" Then
strSQL = "SELECT " & IDField & " , (" & CompoundField & ") AS " & DataField
& " FROM " & Table
Else
strSQL = "SELECT " & IDField & " , " & DataField & " FROM " & Table
End If
If Trim(WhereCondition) <> "" Then strSQL = strSQL & " " & WhereCondition
Set rs = rdConnect.OpenResultset(strSQL, rdOpenForwardOnly)
Do While Not rs.EOF
cbo.AddItem Trim(rs.rdoColumns(1))
'if idfield is not number field then use row count as item data
Select Case rs.rdoColumns(0).Type
Case rdTypeTINYINT, rdTypeSMALLINT, rdTypeINTEGER, rdTypeBIGINT
cbo.ItemData(cbo.NewIndex) = cnvLong(rs.rdoColumns(0), CLng(intRows))
Case Else
cbo.ItemData(cbo.NewIndex) = CLng(intRows)
End Select
intRows = intRows + 1
rs.MoveNext
Loop
Exit_Function:
Set rs = Nothing
LoadComboValues = intRows
Exit Function
Err_Handler:
intRows = -1
Resume Exit_Function
End Function
No comments have been posted about This Function automatically populates standard combo with information typically from database table. Why not be the first to post a comment about This Function automatically populates standard combo with information typically from database table.