-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: saurabhdotnet
Message 4 in Discussion


Hi ! 


I have applied a similar in one of my project. Here is the code :

Private Function makeTB() As String
On Error GoTo errHandler

Dim rs1 As New Recordset

Set grp = Nothing
rs1.Open "Select fldID,fldName,fldUnder,fldNature,fldGross from tblGroup", mCon, 
adOpenDynamic, adLockPessimistic

Do Until rs1.EOF
grp.Add CStr(rs1.Fields(0)), rs1.Fields(0), rs1.Fields(1), rs1.Fields(2), 
(rs1.Fields(3)), "" & (rs1.Fields(4)), CStr(rs1.Fields(0))
rs1.MoveNext
Loop
tv.Nodes.Add , , "U1", "Primary", 2, 3

'The recursive function
GetUnder(1)

rs1.Close

rs1.Open "Select fldID,fldName,fldUnder,fldCBal from tblLedger", mCon, 
adOpenForwardOnly
Do Until rs1.EOF

If (Left(rs1.Fields(3), Len(rs1.Fields(3)) - 3)) <> "" Then
tv.Nodes.Add "U" & rs1.Fields(2), tvwChild, "L" & CStr(rs1.Fields(0)), rs1.Fields(1) & 
" : " & rs1.Fields(3), 1
tv.Nodes("L" & CStr(rs1.Fields(0))).EnsureVisible

Else

tv.Nodes.Add "U" & rs1.Fields(2), tvwChild, "L" & CStr(rs1.Fields(0)), rs1.Fields(1), 1

End If

rs1.MoveNext
Loop

rs1.Close
makeTB = "Groups Updated."

Exit Function

errHandler:
Err.Clear
makeTB = "Groups not Updated."
Resume Next
End Function

'The Recursive Function
Private Function GetUnder(Under As Long)
DoEvents

For Each gr In grp
If gr.Under = Under Then

If gr.Under <> 1 Then
  gr.Nature = grp(CStr(Under)).Nature
  gr.Gross = grp(CStr(Under)).Gross
  End If

  tv.Nodes.Add "U" & CStr(Under), tvwChild, "U" & CStr(gr.ID), gr.gName, 2, 3
  GetUnder gr.ID
  'Under = gr.ID
  'GoTo jj
End If

Next

End Function

This was a VB code which I had written 2 years ago. The code is self explainatory. I 
think you can easily convert it into .NET. In case not, you can revert me back for 
further clarification.

Regards,
Saurabh Verma
0981102223

Microsoft Certified Trainer for .NET
Microsoft Certified Solution Developer for .NET (Early Achiever)
Microsoft Certified Database Administrator


Win Sony Playstation. Win the new Nokia 6610. Jazz up your New Year with Sprite! 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to