can anybody explain me.the use of redim statement and preserve
keyword over here.kindly let me know the idea .any help would be
Highly appreciated.
Public Function LoadData() As Boolean
Dim codeString As String
On Error GoTo LoadData_Error
Dim Obj As IProducts '// The classinterface
Dim rs As ADODB.Recordset '// Recordset to hold the class.Getall call
Dim inxCode As Integer '// Index / offset for recordset id (code) field
Dim i As Integer '// Counter for the array
Dim strItem As String '// String we add to combo box
Dim J As Integer '// Used for iterating columns of the recordset
'// Assume function fails
LoadData = False
i = 0
Select Case ClassName
Case ValidClassNames.cnProducts
Set Obj = New Products
inxCode = ProductFields.fldProductID
Obj.FilterStr = mFilter
Case Else
Err.Raise Number:=10000, description:="Programming error. Unknown class type."
Exit Function
End Select
cmbCodes.Clear
Obj.QueryType = m_queryType
Set rs = Obj.GetAll
If blnDataReturned(rs) Then
If IncludeBlank Then
[B]ReDim mClassCodes(0)[/B]
cmbCodes.AddItem BLANK
mClassCodes(i) = CStr(BLANK_ID)
i = i + 1
End If
mDontFireClickEvent = True
Do Until rs.EOF
strItem = ""
strItem = rs.Fields(1).Value
cmbCodes.AddItem strItem
ReDim Preserve mClassCodes(i)
codeString = IIf(IsNull(rs.Fields(inxCode).Value), NULL_STRING, rs.Fields(inxCode).Value)
codeString = codeString & ";" & m_queryType
mClassCodes(i) = codeString
i = i + 1
rs.MoveNext
Loop
If cmbCodes.ListCount > 0 Then cmbCodes.ListIndex = 0
End If
mDontFireClickEvent = False
Call CloseRecordset(rs)
'Set rs = Nothing
'// Now, if we have a design time default, set it!
If DefaultCode <> NO_DEFAULT Then
Id = DefaultCode
End If
'// All's well - return True
LoadData = True
LoadData_Done:
Exit Function
LoadData_Error:
Call Process_Error(MODULE_NAME, "LoadData")
Resume LoadData_Done
End Function