Drag & Drop Help!! (1 Viewer)

nick.tait

Registered User.
Local time
Today, 10:45
Joined
May 25, 2009
Messages
16
Hi Everyone,
Haven’t posted here for a while but I but every time I have before I’ve always got the answer I was looking for. The problem I’m having at the moment is with a treeview drag and drop code. What i simply want is to be able to drag nodes/sections/data which is in the treeview and move it to another node in the same treeview if that makes sense. I’m still pretty rookie at access and I’m trying to tackle a rather large task. I’ve tried using several codes which I have found on the internet to no avail. Is there anyway someone would be able to help me out? I’m starting to lose hope. My code so far is added bellow however I have deleted all of the codes I have tried... I’m starting fresh. Any help would be much appreciated


Option Compare Database
Option Explicit
Private Sub Custodian_History_Form_Load()

With Me.[Custodian History Form]
.Style = 6
.LineStyle = tvwRootLines
.Indentation = 240
.Appearance = ccFlat
.HideSelection = False
.BorderStyle = ccFixedSingle
.HotTracking = True
.FullRowSelect = True
.Checkboxes = False
.SingleSel = False
.Sorted = False
.Scroll = True
.LabelEdit = tvwManual
.Font.Name = "Verdana"
.Font.Size = 9
End With


Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strQuery1 As String
Dim nod As Object
Dim nodChild As Object
Dim strNode1Text As String
Dim strVisibleText As String
Dim strMessage As String
Dim intVBMsg As Integer
Dim intCounter As Integer
Dim stringcount As String
Dim strQuery2 As String
Dim rs2 As DAO.Recordset
Dim strNode2Text As String
Dim db2 As DAO.Database
Dim rs3 As DAO.Recordset

Me.[Custodian History Form].Nodes.Add Text:="Custodian History", Key:="Custodianhistory987"
strQuery2 = "select DISTINCT Name from [Custodian]"
Set db = CurrentDb
Set rs2 = db.OpenRecordset(strQuery2)
With Me.[Custodian History Form]
Do Until rs2.EOF
strNode2Text = StrConv("Level1" & rs2!Name, vbLowerCase)
strVisibleText = rs2!Name

'if model name is null, will have problem
If IsNull(rs2!Name) Then
MsgBox "number is null"
strVisibleText = "no name"
End If
stringcount = CStr(intCounter)
strNode2Text = strNode2Text + stringcount
Set nod = Me.[Custodian History Form].Nodes.Add(Relative:="Custodianhistory987", relationship:=tvwChild, Key:=strNode2Text, Text:=strVisibleText)


'Now add the child root for this Asset Name
Set rs = db.OpenRecordset("SELECT DISTINCT [user name] FROM custodian WHERE Name='" & rs2("Name") & "'")
Do Until rs.EOF
Set nodChild = .Nodes.Add(Relative:=strNode2Text, relationship:=tvwChild, Text:=rs("user name"))
nodChild.Expanded = False
rs.MoveNext
Loop
rs2.MoveNext

Loop
End With
Set rs2 = Nothing
Set db = Nothing
End Sub
 

Users who are viewing this thread

Top Bottom