Question

lothos12345
06-10-2002, 07:27 AM
Can any one please tell me what the 'lngcount' does in the following code.

Dim lngCount As Long

lbldisplayrec.Visible = False

' If txtbuilderrecordcount = "0" Then
' lbldisplayrec.Visible = True
' Else
' lbldisplayrec.Visible = False
' End If

Set connDB = New ADODB.Connection
connDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data source=c:\VB Project Coding Folder\cardellplus2.mdb"
connDB.Open

Set rstBuilderInfo = New ADODB.Recordset
rstBuilderInfo.ActiveConnection = connDB
rstBuilderInfo.CursorType = adOpenDynamic
rstBuilderInfo.CursorLocation = adUseClient
rstBuilderInfo.LockType = adLockOptimistic
rstBuilderInfo.Open "SELECT [Builder Info].Accountnumber, [Builder Info].Name, [Builder Info].Division, [Builder Info].cardellconnectcontract, [Builder Info].cardellconnectcontractend, " & _
"[Builder record Table].Builderaccount, Count([Builder record Table].BuilderRecordMainID)" & _
"AS CountOfBuilderRecordMainID, [Builder record Table].DateEntered " & _
"FROM [Builder Info] LEFT JOIN [Builder record Table] ON " & _
"[Builder Info].Accountnumber = [Builder record Table].Builderaccount " & _
"GROUP BY [Builder Info].Accountnumber, [Builder Info].Name, [Builder Info].Division, " & _
"[Builder Info].cardellconnectcontract, [Builder Info].cardellconnectcontractend, " & _
"[Builder record Table].Builderaccount, [Builder record Table].DateEntered;"



' get builder info from recordset
ReDim udtBuilders(rstBuilderInfo.RecordCount)

Do While Not (rstBuilderInfo.EOF)
If Not IsNull(rstBuilderInfo.Fields("dateentered").Value) Then
udtBuilders(lngCount).datestartentry = rstBuilderInfo.Fields("dateentered").Value
Else
lbldisplayrec.Visible = True
End If
If (rstBuilderInfo.Fields("dateentered").Value) < (rstBuilderInfo.Fields("CardellConnectContract").Value) Or (rstBuilderInfo.Fields("dateentered").Value) > (rstBuilderInfo.Fields("CardellConnectContractEnd").Value) Then
txtbuilderrecordcount.Text = "0"
Else
udtBuilders(lngCount).builderrecordcount = rstBuilderInfo.Fields("countofBuilderRecordMainID").Value
End If
udtBuilders(lngCount).BuilderName = rstBuilderInfo.Fields("Name").Value & Space(6) & rstBuilderInfo.Fields("Division").Value
udtBuilders(lngCount).BuilderNumber = rstBuilderInfo.Fields("AccountNumber").Value
If Not IsNull(rstBuilderInfo.Fields("CardellConnectContract").Value) Then
udtBuilders(lngCount).ContractStart = rstBuilderInfo.Fields("CardellConnectContract").Value
If Not IsNull(rstBuilderInfo.Fields("CardellConnectContractEnd").Value) Then
udtBuilders(lngCount).ContractEnd = rstBuilderInfo.Fields("CardellConnectContractEnd").Value
Else
udtBuilders(lngCount).ContractEnd = Format(DateValue(udtBuilders(lngCount).ContractStart) + 364, "MM/DD/YYYY")
End If
End If

rstBuilderInfo.MoveNext
lngCount = lngCount + 1

Loop

rstBuilderInfo.Close

' fill in combobox w/ info
' and make link between cbobox and udt
For lngCount = 0 To UBound(udtBuilders)
cboBuilderName.AddItem udtBuilders(lngCount).BuilderName
cboBuilderName.ItemData(cboBuilderName.NewIndex) = lngCount
Next lngCount

End Sub

mhsueh001
06-10-2002, 08:20 AM
It appears that the person who wrote the code is trying to take the items from a recordset (rstBuilderInfo) and place them into a collection/type object (would be my assumption called udtBuilders). The lngCount basically acting as a row counter/row distinguisher for his collection/type as he reads it in.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum