This Function automatically populates standard combo with information typically from database table
This Function automatically populates standard combo with information typically from database tables when using RDO. You need to pass the
Rate This Function automatically populates standard combo with information typically from database table
(2(2 Vote))
'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
This Function automatically populates standard combo with information typically from database table Comments
No comments yet — be the first to post one!
Post a Comment