Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009

    Unhappy Unanswered: Drag & Drop Help!!

    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

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

  2. #2
    Join Date
    Dec 2004
    Madison, WI
    Perhaps this example will help:

    It uses a different technique depending on the mouse events so I'm not sure how it would work with a treeview listbox. Perhaps you can somehow integrate the two methods. It's the best advice I've got.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts