MaximoAccess

Caro Usuário, antes de postar pela primeira vez, leia as regras do fórum.

https://www.maximoaccess.com/t48-regras-do-forum

Obrigado

Administração


Participe do fórum, é rápido e fácil

MaximoAccess

Caro Usuário, antes de postar pela primeira vez, leia as regras do fórum.

https://www.maximoaccess.com/t48-regras-do-forum

Obrigado

Administração

MaximoAccess

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Dicas Ms Access, Exemplos Ms Access, Codigos VBA Ms Access, SQL Ms Access


4 participantes

    [Resolvido]Tree View (Adicionar terceiro nó em controle)

    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 17:54

    Boas Amigos, trabalhando com uma treeView, consigo adicionar dois nós, porém preciso adicionar o terceiro e estou encontrando problemas.

    Ao observar o código verás que

    1- Adiciona o primeiro nó
    2 - utilizando o filtro do primeiro em um segundo recordset vai adicionando o segundo nó (utilizando para isso a relação)

    Pega o primeiro nó e vai adicionando os segundos de acordo com a relação entre tabelas.

    Preciso então realizar um terceiro recordset dentro do segundo, para realizar a adição do terceiro nó.

    Código:

    Option Compare Database
    'Funções para treeView
    '------------------------------------
    '  Define public objects
    Dim rsContas As DAO.Recordset
    Dim rsContasDet As DAO.Recordset
    Dim StrSQL As String




    '===================================================================================================================
    'Funções para treeView
    '===================================================================================================================
    '----------------------
    Private Sub TreeInit()
    '----------------------

    ' Code per example by Robert Kirchner
    ' microsoft.public.access.activexcontrol
    ' Help on treeview (detailed)

    Dim trvTree As Control
    Dim imgList As Control
    Dim nodObject As node
    Dim I As Integer
    Dim rcount As Integer
    Dim strContas As String
    Dim strContasDetalhe As String
    Dim strContasDetSub As String
    Dim strContasDetalheSub As String
    Dim Db As DAO.Database

      ' set database and recordset objects
      Set Db = CurrentDb
      Set trvTree = Me.myTreeView
      Set imgList = Me.MyImageList
     
      ' set Treeview control ImageList property to Image List Object
      ' treeview object style was previously set to 7-TvwTreelinesPlusMinusPictureText
      ' and the images were loaded manually into the imagelist control. Rather
      ' than use the image keys "frame" and "form", the images'
      ' index numbers are used when adding nodes.
     
      trvTree.ImageList = imgList.Object

      ' use two recordsets, one for the parent and the other for the
      ' child.  First create parent node with the linking field as
      ' a root node key.  Next find the first and subsequent children
      ' matching the parent's linking field.  Use the parent node's
      ' node key as the child node's relative value. When you run out
      ' of children, move to next parent record and then find its children,
      ' and so forth until there are no more parents.  I supose this
      ' concept could be used with a third recordset to find children of
      ' the second recordset, and so on.
     
      With trvTree.Nodes
         
          ' clear any nodes, if any
          .Clear
         
          ' open parent and child records
          Set rsContas = Db.OpenRecordset("Conta", dbOpenSnapshot)
          rsContas.MoveLast
          rcount = rsContas.RecordCount
          rsContas.MoveFirst
          Set rsContasDet = Db.OpenRecordset("ContaDetalhes", dbOpenSnapshot)
           
    ' loop through recordset and add nodes
    While Not (rsContas.EOF)

      strContas = rsContas!ID_conta
     
      ' concatenate fields to create the parent node text value.
      If Len(Trim(Nz(rsContas!PlanoConta))) > 0 Then
          strContas = Format(strContas, ">") & ", " & rsContas!PlanoConta
      End If
     
      ' .. e adiciona o  noode do tipo de conta no Treeview
      Set nodObject = .Add(, , "A" & CStr(rsContas!ID_conta), strContas, 1)
      StrSQL = "ID_Conta = " & rsContas!ID_conta
         
      'find first child, if any, belonging to this parent
      rsContasDet.FindFirst StrSQL
      'on Error GoTo NoContaDetalhe
     
      ' concatenate fields to create the child node text value.
      While Not (rsContasDet.NoMatch)
          If IsNull(rsContasDet!ID_conta) Then GoTo NoContaDetalhe
          'strContasDetalhe = rsContasDet!TipoConta
          If Len(Trim(Nz(rsContasDet!TipoConta))) > 0 Then
            strContasDetalhe = rsContasDet!TipoConta
          End If
          ' .. and add thee child node to the Treeview
              Set nodObject = .Add("A" & rsContas!ID_conta, tvwChild, "C" & rsContasDet!ID_Detalhes, strContasDetalhe, 2)
                     
              '.. and create the node tag property holding key to child's baptism
            trvTree.Nodes("C" & rsContasDet!ID_Detalhes).Tag = rsContasDet!ID_Detalhes
           
          ' Now find next child, if any
          rsContasDet.FindNext StrSQL
         
      ' .. and loop back and add next child
      Wend
    NoContaDetalhe:

      ' não move Tipo de Conta, move para proximo plano Conta
      rsContas.MoveNext
      Wend
    End With


    Set rsContas = Nothing
    Set rsContasDet = Nothing
    End Sub

    [Resolvido]Tree View (Adicionar terceiro nó em controle) TreeView
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 18:10

    Tentei adicionar o terceiro mas deu ítem não encontrado nessa coleção


    '----------------------
    Private Sub TreeInit()
    '----------------------

    ' Code per example by Robert Kirchner
    ' microsoft.public.access.activexcontrol
    ' Help on treeview (detailed)

    Dim trvTree As Control
    Dim imgList As Control
    Dim nodObject As node
    Dim I As Integer
    Dim rcount As Integer
    Dim strContas As String
    Dim strContasDetalhe As String
    Dim strContasDetSub As String
    Dim strContasDetalheSub As String
    Dim Db As DAO.Database

    ' set database and recordset objects
    Set Db = CurrentDb
    Set trvTree = Me.myTreeView
    Set imgList = Me.MyImageList

    ' set Treeview control ImageList property to Image List Object
    ' treeview object style was previously set to 7-TvwTreelinesPlusMinusPictureText
    ' and the images were loaded manually into the imagelist control. Rather
    ' than use the image keys "frame" and "form", the images'
    ' index numbers are used when adding nodes.

    trvTree.ImageList = imgList.Object

    ' use two recordsets, one for the parent and the other for the
    ' child. First create parent node with the linking field as
    ' a root node key. Next find the first and subsequent children
    ' matching the parent's linking field. Use the parent node's
    ' node key as the child node's relative value. When you run out
    ' of children, move to next parent record and then find its children,
    ' and so forth until there are no more parents. I supose this
    ' concept could be used with a third recordset to find children of
    ' the second recordset, and so on.

    With trvTree.Nodes

    ' clear any nodes, if any
    .Clear

    ' open parent and child records
    Set rsContas = Db.OpenRecordset("Conta", dbOpenSnapshot)
    rsContas.MoveLast
    rcount = rsContas.RecordCount
    rsContas.MoveFirst
    Set rsContasDet = Db.OpenRecordset("ContaDetalhes", dbOpenSnapshot)
    Set rsContasDetSub = Db.OpenRecordset("ContaDetalhesSub", dbOpenSnapshot)

    ' loop through recordset and add nodes
    While Not (rsContas.EOF)

    strContas = rsContas!ID_conta

    ' concatenate fields to create the parent node text value.
    If Len(Trim(Nz(rsContas!PlanoConta))) > 0 Then
    strContas = Format(strContas, ">") & ", " & rsContas!PlanoConta
    End If

    ' .. e adiciona o noode do tipo de conta no Treeview
    Set nodObject = .Add(, , "A" & CStr(rsContas!ID_conta), strContas, 1)
    StrSQL = "ID_Conta = " & rsContas!ID_conta

    'find first child, if any, belonging to this parent
    rsContasDet.FindFirst StrSQL
    'on Error GoTo NoContaDetalhe

    ' concatenate fields to create the child node text value.
    While Not (rsContasDet.NoMatch)
    If IsNull(rsContasDet!ID_conta) Then GoTo NoContaDetalhe
    'strContasDetalhe = rsContasDet!TipoConta
    If Len(Trim(Nz(rsContasDet!TipoConta))) > 0 Then
    strContasDetalhe = rsContasDet!TipoConta
    End If
    ' .. and add thee child node to the Treeview
    Set nodObject = .Add("A" & rsContas!ID_conta, tvwChild, "C" & rsContasDet!ID_Detalhes, strContasDetalhe, 2)

    StrSQL1 = "ID_Detalhes = " & rsContasDet!ID_Detalhes

    '.. and create the node tag property holding key to child's baptism
    trvTree.Nodes("C" & rsContasDet!ID_Detalhes).Tag = rsContasDet!ID_Detalhes

    ' Now find next child, if any
    rsContasDet.FindNext StrSQL1

    ' .. and loop back and add next child

    '==========================================================================================================================
    While Not (rsContasDetSub.NoMatch)
    If IsNull(rsContasDetSub!ID_Detalhes) Then GoTo NoContaDetalheSub

    If Len(Trim(Nz(rsContasDetSub!Descricao))) > 0 Then
    strContasDetalheSub = rsContasDetSub!Descricao
    End If
    ' .. and add thee child node to the Treeview
    Set nodObject = .Add("C" & rsContasDet!IDDetalhes, tvwChild, "D" & rsContasDetSub!ID_DetalhesSub, strContasDetalheSub, 3)

    '.. and create the node tag property holding key to child's baptism
    trvTree.Nodes("D" & rsContasDetSub!ID_DetalhesSub).Tag = rsContasDetSub!ID_DetalhesSub

    ' Now find next child, if any
    rsContasDetSub.FindNext StrSQL1

    ' .. and loop back and add next child
    '============================================================================================================================

    Wend


    NoContaDetalhe:

    ' não move Tipo de Conta, move para proximo plano Conta
    rsContasDet.MoveNext
    Wend

    NoContaDetalheSub:

    ' não move Tipo de Conta, move para proximo plano Conta
    rsContasDetSub.MoveNext
    Wend
    End With


    Set rsContas = Nothing
    Set rsContasDet = Nothing
    End Sub
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 18:19

    Amigos começou a adicionar, porem em um loop do recorset deu o seguinte erro:

    Key is not unique in collection e remeteu para a linha em vermelho:


    '===================================================================================================================
    'Funções para treeView
    '===================================================================================================================
    '----------------------
    Private Sub TreeInit()
    '----------------------

    ' Code per example by Robert Kirchner
    ' microsoft.public.access.activexcontrol
    ' Help on treeview (detailed)

    Dim trvTree As Control
    Dim imgList As Control
    Dim nodObject As node
    Dim I As Integer
    Dim rcount As Integer
    Dim strContas As String
    Dim strContasDetalhe As String
    Dim strContasDetSub As String
    Dim strContasDetalheSub As String
    Dim Db As DAO.Database

    ' set database and recordset objects
    Set Db = CurrentDb
    Set trvTree = Me.myTreeView
    Set imgList = Me.MyImageList

    ' set Treeview control ImageList property to Image List Object
    ' treeview object style was previously set to 7-TvwTreelinesPlusMinusPictureText
    ' and the images were loaded manually into the imagelist control. Rather
    ' than use the image keys "frame" and "form", the images'
    ' index numbers are used when adding nodes.

    trvTree.ImageList = imgList.Object

    ' use two recordsets, one for the parent and the other for the
    ' child. First create parent node with the linking field as
    ' a root node key. Next find the first and subsequent children
    ' matching the parent's linking field. Use the parent node's
    ' node key as the child node's relative value. When you run out
    ' of children, move to next parent record and then find its children,
    ' and so forth until there are no more parents. I supose this
    ' concept could be used with a third recordset to find children of
    ' the second recordset, and so on.

    With trvTree.Nodes

    ' clear any nodes, if any
    .Clear

    ' open parent and child records
    Set rsContas = Db.OpenRecordset("Conta", dbOpenSnapshot)
    rsContas.MoveLast
    rcount = rsContas.RecordCount
    rsContas.MoveFirst
    Set rsContasDet = Db.OpenRecordset("ContaDetalhes", dbOpenSnapshot)
    Set rsContasDetSub = Db.OpenRecordset("ContaDetalhesSub", dbOpenSnapshot)

    ' loop through recordset and add nodes
    While Not (rsContas.EOF)

    strContas = rsContas!ID_conta

    ' concatenate fields to create the parent node text value.
    If Len(Trim(Nz(rsContas!PlanoConta))) > 0 Then
    strContas = Format(strContas, ">") & ", " & rsContas!PlanoConta
    End If

    ' .. e adiciona o noode do tipo de conta no Treeview
    Set nodObject = .Add(, , "A" & CStr(rsContas!ID_conta), strContas, 1)
    StrSQL = "ID_Conta = " & rsContas!ID_conta

    'find first child, if any, belonging to this parent
    rsContasDet.FindFirst StrSQL
    'on Error GoTo NoContaDetalhe

    ' concatenate fields to create the child node text value.
    While Not (rsContasDet.NoMatch)
    If IsNull(rsContasDet!ID_conta) Then GoTo NoContaDetalhe
    'strContasDetalhe = rsContasDet!TipoConta
    If Len(Trim(Nz(rsContasDet!TipoConta))) > 0 Then
    strContasDetalhe = rsContasDet!TipoConta
    End If
    ' .. and add thee child node to the Treeview
    Set nodObject = .Add("A" & rsContas!ID_conta, tvwChild, "C" & rsContasDet!ID_Detalhes, strContasDetalhe, 2)

    StrSQL1 = "ID_Detalhes = " & rsContasDet!ID_Detalhes

    '.. and create the node tag property holding key to child's baptism
    trvTree.Nodes("C" & rsContasDet!ID_Detalhes).Tag = rsContasDet!ID_Detalhes

    ' Now find next child, if any
    rsContasDet.FindNext StrSQL1

    ' .. and loop back and add next child

    '==========================================================================================================================
    While Not (rsContasDetSub.NoMatch)
    If IsNull(rsContasDetSub!ID_Detalhes) Then GoTo NoContaDetalheSub

    If Len(Trim(Nz(rsContasDetSub!Descricao))) > 0 Then
    strContasDetalheSub = rsContasDetSub!Descricao
    End If
    ' .. and add thee child node to the Treeview
    'Set nodObject = .Add("A" & rsContas!ID_conta, tvwChild, "C" & rsContasDet!ID_Detalhes, strContasDetalhe, 2)
    Set nodObject = .Add("C" & rsContasDet!ID_Detalhes, tvwChild, "D" & rsContasDetSub!ID_DetalhesSub, strContasDetalheSub, 3)

    '.. and create the node tag property holding key to child's baptism
    trvTree.Nodes("D" & rsContasDetSub!ID_DetalhesSub).Tag = rsContasDetSub!ID_DetalhesSub

    ' Now find next child, if any
    rsContasDetSub.FindNext StrSQL1

    ' .. and loop back and add next child
    '============================================================================================================================

    Wend


    NoContaDetalhe:

    ' não move Tipo de Conta, move para proximo plano Conta
    rsContasDet.MoveNext
    Wend

    NoContaDetalheSub:

    ' não move Tipo de Conta, move para proximo plano Conta
    rsContasDetSub.MoveNext
    Wend
    End With


    Set rsContas = Nothing
    Set rsContasDet = Nothing
    End Sub
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 4/6/2012, 18:35

    Olá, amigo Hary

    O TreeView é um controlo de muita paciência.
    Não estou a "ver" a construção da árvore. Tente verificar passo-a-passo o valor de cada variável e de execução. Se não conseguir, mande a bd com os dados para ver se lhe consigo ajudar.
    Abraço,
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 19:07

    Não consegui amigao.. ja esquentei a cuca aqui..

    Se puder me ajudar..

    O codigo no exemplo esta alterado..

    qualquer coisa cole o codigo original na primeira mensagem.

    Abraços.

    https://dl.dropbox.com/u/26441349/TreeView.rar
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 19:28

    Como eu fiz no exemplo, comeca a adiconar porém nao está seguindo o relacionamento.

    Cumprimentos.
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 4/6/2012, 19:43

    Hary,

    O erro que dá ao carregar é por querer criar uma chave (para o nó) já existente. Cada nó tem de ter chave única.
    Pode tentar resolver, que eu continuo a tentar...
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 19:49

    Se observa eu utilizei mesma lógica do segundo nó.. porem nao deu certo...
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 4/6/2012, 19:51

    Hary,

    Vou tentar criar o código assim:
    Crio o Rst1, rst2 e rst3
    em cada passo de rst1 filtro rst2 e em cada passo de rst2 filtro rst3.
    É assim a mecânica do preenchimento?
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 20:03

    Pelo que entendi a lógica do gajo que fez o código é assim mesmo

    Cria o primeiro nó, filta o segundo e preenche

    Ao criar o segundo nó filtra e preenche

    Ai vai para o proximo primeiro no, repetindo a lógica


    Ai vai criando

    No1 xxxxxxx
    Sub No xxxxxx
    Sub No xxxxxxxxxx

    Loop

    No1 xxxxxxx
    Sub No xxxxxx
    Sub No xxxxxxxxxx


    No2 dddddddd
    Sub No dddddddd
    Sub No dddddddd


    avatar
    João afonso
    Avançado
    Avançado


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 396
    Registrado : 24/05/2011

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  João afonso 4/6/2012, 20:11

    Harysohn

    Criei um exemplo com suas tabelas, o treeView não é tão bonitinho porem apresenta os 3 nós
    o exemplo busca informações da consultaTreeview.
    Anexos
    [Resolvido]Tree View (Adicionar terceiro nó em controle) AttachmentTreeView.zip
    Você não tem permissão para fazer download dos arquivos anexados.
    (34 Kb) Baixado 122 vez(es)
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 20:33

    Boas João Afonso, obrigado pelo exemplo, ficou muito bom.

    No entanto eu ja trabalho com esse modelo que enviei em outros forms,
    e nele ao clique de cada linha da tree me retorna valores ali contidos e utilizo estes valores para lançamentos ou alterações na propria tabela diretamente...

    Digamos que este exemplo que enviei como trabalha diretamente com a tabela, permite uma maior funcionalidade do que pretendo.

    Mas seu exemplo é muito bom, e o aproveitarei em outras ocasiões.

    Grato.
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 4/6/2012, 21:35

    Hary,

    Cole este código no módulo e veja se é isto:

    Option Compare Database
    Option Explicit
    Dim MsgErro As String
    Dim Incluir As Boolean
    Dim StrTMP As String
    '====================================
    'Funções para treeView
    '------------------------------------
    ' Define public objects
    Dim rsContas As DAO.Recordset
    Dim rsContasDet As DAO.Recordset
    Dim rsContasDetSub As DAO.Recordset
    Dim StrSQL, StrSQL1 As String
    '=====================================

    '-------------------------
    Private Sub Form_Current()
    '-------------------------
    ' form open with focus in search field
    Me.FindTipoConta.SetFocus
    End Sub


    Private Sub Form_Load()
    '===========================================================
    'Função para treeview
    With Me.myTreeView
    ' set style property to value that allows pictures
    .Style = tvwTreelinesPlusMinusPictureText
    ' set to automatically expand selected node and collapse previous node
    '.SingleSel = True ' Single Selection
    End With
    ' initialize tree
    TreeInit
    End Sub

    '===================================================================================================================
    'Funções para treeView
    '===================================================================================================================
    '----------------------
    Private Sub TreeInit()
    '----------------------

    ' Code per example by Robert Kirchner
    ' microsoft.public.access.activexcontrol
    ' Help on treeview (detailed)

    Dim trvTree As Control
    Dim imgList As Control
    Dim nodObject As node
    Dim I As Integer
    Dim rcount As Integer
    Dim strContas As String
    Dim strContasDetalhe As String
    Dim strContasDetalheSub As String
    Dim Db As DAO.Database

    ' set database and recordset objects
    Set Db = CurrentDb
    Set trvTree = Me.myTreeView
    Set imgList = Me.MyImageList

    ' set Treeview control ImageList property to Image List Object
    ' treeview object style was previously set to 7-TvwTreelinesPlusMinusPictureText
    ' and the images were loaded manually into the imagelist control. Rather
    ' than use the image keys "frame" and "form", the images'
    ' index numbers are used when adding nodes.

    trvTree.ImageList = imgList.Object

    ' use two recordsets, one for the parent and the other for the
    ' child. First create parent node with the linking field as
    ' a root node key. Next find the first and subsequent children
    ' matching the parent's linking field. Use the parent node's
    ' node key as the child node's relative value. When you run out
    ' of children, move to next parent record and then find its children,
    ' and so forth until there are no more parents. I supose this
    ' concept could be used with a third recordset to find children of
    ' the second recordset, and so on.

    With trvTree.Nodes

    ' clear any nodes, if any
    .Clear

    ' open parent and child records
    Set rsContas = Db.OpenRecordset("Conta", dbOpenSnapshot)
    rsContas.MoveLast
    rcount = rsContas.RecordCount
    rsContas.MoveFirst
    'Set rsContasDet = Db.OpenRecordset("ContaDetalhes", dbOpenSnapshot)
    'Set rsContasDetSub = Db.OpenRecordset("ContaDetalhesSub", dbOpenSnapshot)

    ' loop through recordset and add nodes
    Do While Not rsContas.EOF
    strContas = rsContas!ID_conta

    ' concatenate fields to create the parent node text value.
    If Len(Trim(Nz(rsContas!PlanoConta))) > 0 Then
    strContas = Format(strContas, ">") & ", " & rsContas!PlanoConta
    End If

    ' .. e adiciona o noode do tipo de conta no Treeview
    Set nodObject = .Add(, , "A" & CStr(rsContas!ID_conta), strContas, 1)
    'StrSQL = "ID_Conta = " & rsContas!ID_conta

    'find first child, if any, belonging to this parent
    'rsContasDet.FindFirst StrSQL
    'on Error GoTo NoContaDetalhe

    ' concatenate fields to create the child node text value.
    'While Not (rsContasDet.NoMatch)
    'Set rsContasDet = Db.OpenRecordset("ContaDetalhes", dbOpenSnapshot)
    Set rsContasDet = Db.OpenRecordset("SELECT * FROM ContaDetalhes WHERE [ID_Conta] = " & rsContas!ID_conta, dbOpenSnapshot)
    Do While Not rsContasDet.EOF
    If IsNull(rsContasDet!ID_conta) Then GoTo NoContaDetalhe
    'strContasDetalhe = rsContasDet!TipoConta
    If Len(Trim(Nz(rsContasDet!TipoConta))) > 0 Then
    strContasDetalhe = rsContasDet!TipoConta
    End If
    ' .. and add thee child node to the Treeview
    Set nodObject = .Add("A" & rsContas!ID_conta, tvwChild, "C" & rsContasDet!ID_Detalhes, strContasDetalhe, 2)
    'StrSQL1 = "ID_Detalhes = " & rsContasDet!ID_Detalhes

    '.. and create the node tag property holding key to child's baptism
    trvTree.Nodes("C" & rsContasDet!ID_Detalhes).Tag = rsContasDet!ID_Detalhes

    ' Now find next child, if any
    'rsContasDet.FindNext StrSQL

    '==========================================================================================================================
    Set rsContasDetSub = Db.OpenRecordset("SELECT * FROM ContaDetalhesSub WHERE ID_Detalhes = " & rsContasDet!ID_Detalhes, dbOpenSnapshot)
    Do While Not rsContasDetSub.EOF
    If IsNull(rsContasDetSub!ID_DetalhesSub) Then GoTo NoContaDetalheSub

    If Len(Trim(Nz(rsContasDetSub!Descricao))) > 0 Then
    strContasDetalheSub = rsContasDetSub!Descricao
    End If
    ' .. and add thee child node to the Treeview
    'Set nodObject = .Add("A" & rsContas!ID_conta, tvwChild, "C" & rsContasDet!ID_Detalhes, strContasDetalhe, 2)
    Set nodObject = .Add("C" & rsContasDet!ID_Detalhes, tvwChild, "E" & rsContasDetSub!ID_DetalhesSub, strContasDetalheSub, 3)

    '.. and create the node tag property holding key to child's baptism
    trvTree.Nodes("E" & rsContasDetSub!ID_DetalhesSub).Tag = rsContasDetSub!ID_DetalhesSub

    ' Now find next child, if any
    NoContaDetalheSub:
    'rsContasDetSub.FindNext StrSQL1
    rsContasDetSub.MoveNext

    ' .. and loop back and add next child
    '============================================================================================================================
    Loop

    NoContaDetalhe:

    ' não move Tipo de Conta, move para proximo plano Conta
    rsContasDet.MoveNext
    Loop
    ' não move Tipo de Conta, move para proximo plano Conta
    rsContas.MoveNext
    Loop
    End With


    Set rsContas = Nothing
    Set rsContasDet = Nothing
    End Sub

    '----------------------------
    Private Sub cmdSearch_Click()
    '----------------------------
    Dim strSearch As String

    ' if search field contains a value
    If Not IsNull(FindTipoConta) Then
    strSearch = Me.FindTipoConta.Value

    ' .. find a node like the value
    MyTreeview_FindNodeLike (strSearch)
    End If

    '.. and set the focus to Treeciew control
    Me.myTreeView.SetFocus

    End Sub

    '-----------------------------------
    Private Sub FindChild_AfterUpdate()
    '-----------------------------------

    ' if search field has a value
    If Not IsNull(Me.FindTipoConta) Then
    ' .. then call search button click event
    cmdSearch_Click
    End If
    End Sub


    '-------------------------------
    Private Sub MyTreeView_DblClick()
    '-------------------------------
    ' call sub to react to double-click. Number 2 indicates
    ' that call is being made by a double-click action
    Call DisplayForm(2)
    End Sub

    '-------------------------------
    Private Sub MyTreeView_Click()
    '-------------------------------
    ' call sub to react to double-click. Number 2 indicates
    ' that call is being made by a double-click action
    Call DisplayForm(2)
    End Sub

    '---------------------------------------------
    Function MyTreeview_FindNode(strKey As String)
    '---------------------------------------------

    ' define a control
    Dim trvTree As Control

    ' .. and set to Treeview
    Set trvTree = Me.myTreeView

    ' make node selected
    trvTree.Nodes(strKey).Selected = True

    ' .. and insure node is visible
    trvTree.Nodes(trvTree.SelectedItem.Index).EnsureVisible

    ' and expand selected node, if desired
    'trvTree.Object.SelectedItem.Expanded = True

    End Function

    '-----------------------------------------------
    Function MyTreeview_FindNodeLike(C As String)
    '-----------------------------------------------

    ' set up SQL string to select a father like search string
    StrSQL = "SELECT ID_Detalhes,TipoConta from ContaDetalhes WHERE [TipoConta] LIKE """ & _
    Me.FindTipoConta & "*"" ORDER BY TipoConta"

    ' open recordset
    Set rsContasDet = CurrentDb.OpenRecordset(StrSQL)
    ' .. and it recordset contains no records then exit
    If rsContasDet.BOF Or rsContasDet.EOF Then Exit Function
    ' .. otherwise move to first record
    rsContasDet.MoveFirst
    ' .. and trigger event to find that node
    MyTreeview_FindNode ("C" & CStr(rsContasDet!ID_Detalhes))

    End Function

    '------------------------------------------------------------------------
    Private Sub MyTreeview_KeyDown(KeyCode As Integer, ByVal Shift As Integer)
    '------------------------------------------------------------------------
    ' pressing space is same action as double-click
    If (KeyCode = vbKeyShift) And acShiftMask Then

    ' call sub to react to shift key press. Number 1 indicates
    ' that call is being made by a press of shift key

    Call DisplayForm(1) 'MyTreeView_DblClick
    End If
    End Sub

    '----------------------------
    Sub DisplayForm(I As Integer)
    '----------------------------

    ' for this Treeview I do not want a double-click on a parent node
    ' to open the applicable marriage form, but pressing the shift key
    ' should open the marriage form applicable to the parent node. Shift
    ' or double-click on a child node should open the child's applicable
    ' baptism form.

    Dim strKey As String
    Dim strTag As String
    Dim strFilter As String

    ' get key of selected node
    strKey = Me.myTreeView.SelectedItem.Key
    ' .. then get node's tag proterty
    strTag = Nz(Me.myTreeView.Nodes(strKey).Tag, "")

    ' .. then if there is a tag value
    If Len(strTag) > 0 Then

    '.. then get the initial letter of node key
    Select Case Left(strKey, 1)

    ' .. and open the the appropriate form filter by tag value
    Case "A"

    ' if parent node then a double-click expands node
    ' but does not open marriage form
    If I = 2 Then Exit Sub
    'strFilter = "DoCmd.OpenForm ""frmMarriages"", , , " & _
    "RecordNo = """ & strTag & """"
    Case "C"
    Me.txtIDLst = strTag
    Me.txtConta = DLookup("TipoConta", "ContaDetalhes", "ID_Detalhes =" & strTag)
    End Select
    End If
    End Sub
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 21:52

    Grande Alexandre.. Meu amigo Mister "M" hehe


    Poderia dar uma breve explicação sobre o problema e solução?

    Obrigado!
    avatar
    Convidad
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidad 4/6/2012, 22:11


    Mestre Alexandre

    Meus respeitos!

    Um dia eu chego lá...

    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 22:16

    Boas Alexandre, percebi que a tua solução ficou mais eficaz que a original.

    Vi que retirou o Wend e o substituiu pelo loop,
    e já iniciou o loop com o recordset filtrado pelo recordset anterior.

    Ficou muito melhor e de mais fácil compreensão.

    João Afonso, obrigado pela disposição em ajudar.


    Abraços.
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 4/6/2012, 22:21

    Hary,

    No ciclo do rsContasDetSub, colocou While Not (rsContasDet.EOF) em vez de While Not (rsContasDetSub.EOF)
    Dentro deste ciclo, invocava o nó "E" & rsContasDetSub!ID_Detalhes, quando devia invocar o nó "E" & rsContasDetSub!ID_DetalhesSub
    Colocava o ponto NoContaDetalheSub fora do ciclo
    Abraço,
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 4/6/2012, 22:37

    O código com os devidos creditos, e retirado o desnecessário, com breve explicação dos passos.

    '===================================================================================================================
    'Funções para treeView
    '===================================================================================================================
    '----------------------
    Private Sub TreeInit()
    '----------------------

    ' Code per example by Robert Kirchner
    ' microsoft.public.access.activexcontrol
    ' Help on treeview (detailed)
    'Adaptação executada por Alexandre Neves
    'FÓRUM MÁXIMO ACCESS
    'Em 04/06/2012

    Dim trvTree As Control
    Dim imgList As Control
    Dim nodObject As node
    Dim I As Integer
    Dim rcount As Integer
    Dim strContas As String
    Dim strContasDetalhe As String
    Dim strContasDetalheSub As String
    Dim Db As DAO.Database

    'seta o banco de dados
    Set Db = CurrentDb
    Set trvTree = Me.myTreeView
    Set imgList = Me.MyImageList


    trvTree.ImageList = imgList.Object
    With trvTree.Nodes

    ' limpa os possíveis nós existentes
    .Clear

    '==========================================================================================================================
    'PARA O PRIMEIRO NÓ
    '==========================================================================================================================
    'Seta o recordset para o primeiro nó
    Set rsContas = Db.OpenRecordset("Conta", dbOpenSnapshot)
    rsContas.MoveLast
    rcount = rsContas.RecordCount
    rsContas.MoveFirst

    'executa o loop pelo recorset adicionando o primeiro nó à treeview
    Do While Not rsContas.EOF
    strContas = rsContas!ID_conta

    'Concatena os campos para criar o texto do nó
    If Len(Trim(Nz(rsContas!PlanoConta))) > 0 Then
    strContas = Format(strContas, ">") & ", " & rsContas!PlanoConta
    End If

    'Adiciona o noode do tipo de conta no Treeview
    Set nodObject = .Add(, , "A" & CStr(rsContas!ID_conta), strContas, 1)

    '==========================================================================================================================
    'PARA O SEGUNDO NÓ
    '==========================================================================================================================
    'Seta o recordset para o segundo nó, observe que ele é filtrado pelo parâmetro do recordset anterior
    Set rsContasDet = Db.OpenRecordset("SELECT * FROM ContaDetalhes WHERE [ID_Conta] = " & rsContas!ID_conta, dbOpenSnapshot)
    'executa o loop pelo recorset adicionando o primeiro nó à treeview
    Do While Not rsContasDet.EOF
    'se o recordset tiver valor nulo vai para a linha NoContaDetalhe
    If IsNull(rsContasDet!ID_conta) Then GoTo NoContaDetalhe

    If Len(Trim(Nz(rsContasDet!TipoConta))) > 0 Then
    strContasDetalhe = rsContasDet!TipoConta
    End If
    'Adiciona os nós conforme o segundo recordset
    Set nodObject = .Add("A" & rsContas!ID_conta, tvwChild, "C" & rsContasDet!ID_Detalhes, strContasDetalhe, 2)
    '.. cria o nó e a propriedade tag
    trvTree.Nodes("C" & rsContasDet!ID_Detalhes).Tag = rsContasDet!ID_Detalhes

    '==========================================================================================================================
    'PARA O TERCEIRO NÓ
    '==========================================================================================================================
    Set rsContasDetSub = Db.OpenRecordset("SELECT * FROM ContaDetalhesSub WHERE ID_Detalhes = " & rsContasDet!ID_Detalhes, dbOpenSnapshot)
    Do While Not rsContasDetSub.EOF
    'se o recordset tiver valor nulo vai para a linha NoContaDetalhe
    If IsNull(rsContasDetSub!ID_DetalhesSub) Then GoTo NoContaDetalheSub
    'Concatena os campos para criar o texto do nó
    If Len(Trim(Nz(rsContasDetSub!Descricao))) > 0 Then
    strContasDetalheSub = rsContasDetSub!Descricao
    End If
    'Adiciona os nós conforme o segundo recordset
    Set nodObject = .Add("C" & rsContasDet!ID_Detalhes, tvwChild, "E" & rsContasDetSub!ID_DetalhesSub, strContasDetalheSub, 3)
    'cria o nó e a propriedade tag
    trvTree.Nodes("E" & rsContasDetSub!ID_DetalhesSub).Tag = rsContasDetSub!ID_DetalhesSub
    '-------------------------------------------------------------------------------------------------------------------------

    NoContaDetalheSub:
    rsContasDetSub.MoveNext

    Loop
    NoContaDetalhe:
    rsContasDet.MoveNext
    Loop
    rsContas.MoveNext
    Loop
    End With

    'Limpa os recordset's envolvidos
    Set rsContas = Nothing
    Set rsContasDet = Nothing
    Set rsContasDetSub = Nothing
    End Sub


    Abraços.
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 5/6/2012, 12:45

    Para quem está a acompanhar o tópico, a busca na treeview do texto digitado na caixa de pesquisa, para as duas tabelas (nós)


    '-----------------------------------------------
    Function MyTreeview_FindNodeLike(C As String)
    '-----------------------------------------------

    ' set up a SQL para realizar a busca na primeira tabela
    StrSQL = "SELECT ID_Detalhes,TipoConta from ContaDetalhes WHERE [TipoConta] LIKE """ & _
    Me.FindTipoConta & "*"" ORDER BY TipoConta"

    ' abre o recordset
    Set rsContasDet = CurrentDb.OpenRecordset(StrSQL)

    ' Se no recordset nao contem o texto vai para o próximo nó
    If rsContasDet.BOF Or rsContasDet.EOF Then GoTo ContinuaProximoNo
    ' Caso contrario move para o primento registro
    rsContasDet.MoveFirst
    'Busca no nó C
    MyTreeview_FindNode ("C" & CStr(rsContasDet!ID_Detalhes))
    Exit Function
    ContinuaProximoNo:
    ' set up a SQL para realizar a busca na segunda tabela
    StrSQL = "SELECT ID_DetalhesSub,Descricao from ContaDetalhesSub WHERE [Descricao] LIKE """ & _
    Me.FindTipoConta & "*"" ORDER BY Descricao"

    Set rsContasDetSub = CurrentDb.OpenRecordset(StrSQL)
    ' Se no recordset nao contem o texto encerra a função emitindo mensagem
    If rsContasDetSub.BOF Or rsContasDetSub.EOF Then MsgBox "Registro não encontrado", vbInformation, "Atenção": Exit Function
    ' Caso contrario move para o primento registro
    rsContasDetSub.MoveFirst
    ' Busca no nó E
    MyTreeview_FindNode ("E" & CStr(rsContasDetSub!ID_DetalhesSub))
    End Function


    Cumprimentos.
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 5/6/2012, 20:30

    Boas Alexandre, novamente..

    Postarei no mesmo tópico pois o objeto de duvida ainda é a treeview..

    Tenho um codigo que ao clicar na lista (No texto correspondente) ele retorna o Tag (A, B ou C)

    E remete para um case.

    Código:

    '----------------------------
    Sub DisplayForm(I As Integer)
    '----------------------------
      Dim strKey As String
      Dim strTag As String
      Dim strFilter As String
     
      ' Pega a chave do nó selecionado
      strKey = Me.myTreeView.SelectedItem.Key
      ' .. em seguida, obtem  a propriedade do tag do nó
      strTag = Nz(Me.myTreeView.Nodes(strKey).Tag, "")
     
      ' .. then if there is a tag value
      If Len(strTag) >= 0 Then
          'Obtem a letra do tag
          Select Case Left(strKey, 1)
         
            'Executa a operação conforme o nó selecionado de acordo com o valor do tag
            Case "A"
                Me.txtIdConta = DLookup("ID_Conta", "Conta", "Id_Conta =" & Mid(strKey, 2, 4))
                Me.txtConta = DLookup("PlanoConta", "Conta", "Id_Conta =" & Mid(strKey, 2, 4))
               
            Case "C"
                Me.txtIDTipo = strTag
                Me.txtTipo = DLookup("TipoConta", "ContaDetalhes", "ID_Detalhes =" & strTag)
           
            Case "E"
                Me.txtIDDesc = strTag
                Me.txtDescricao = DLookup("Descricao", "ContaDetalhesSub", "ID_DetalhesSub =" & strTag)
         
          End Select
      End If
    End Sub


    E assim vou preenhendo os campos no form conforme a expansão da tree...

    Ocorre que se clicar no sinal de + para expandir ao inves de clicar no texto...

    O tag não é selecionado, não preenchendo os campos no form.

    Suponto que o usuário clique no primeiro +, depois no segundo + e no terceiro nó clica no texto...

    So será preenchido os caixas texto no form referente a apenas o ultimo no.


    Sera que tem como na occorrencia desse fato pelo usuario (clicar apenas no +) ao clicar no texto do ultimo nó, me retornar as ID's correspoentes do No A e C?


    Cumprimentos.
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 5/6/2012, 20:39

    Boas, Hary

    Não exercitei a sua dúvida mas, pela explanação, parece-me aconselhável que, logo ao carregar a árvore, a descrição seja carregada. Além de nada custar, não obriga ao peso das chamadas DLookup que possam ser necessárias.
    Tente carregar tudo na construção da árvore, se precisar avise
    Lupércio
    Lupércio
    VIP
    VIP


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 1143
    Registrado : 07/05/2011

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Lupércio 5/6/2012, 20:48

    Eu estava aqui acompanhando humildemente o tópico.

    É de tirar o xapéu mesmo, para você Alexandre e olha que o Hary o Norberto são duas feras, e o fato do reconhecimento tanto do Hary como do Norberto, mas é por isso que este forum só tende a se expandir, cheio de jóias raras do access, parabéns á todos!

    Abraços!
    Lupércio
    Lupércio
    VIP
    VIP


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 1143
    Registrado : 07/05/2011

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Lupércio 5/6/2012, 20:53

    Peço desculpas aos três: Alexandre, Hary e ao Norberto, por eu escrever essas linhas, porque escrever sobre vocês é super difícil.
    Laughing
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 5/6/2012, 21:12

    Boas alexandre, eu utilizo isso em um form de consulta para lancar os dados em outro form, para adicionar lançamentos no caixa..

    Entao o usuario vai realizar um lancamento, exemplo:

    Despesas...Clica
    Compras...Clica
    Refrigerantes...Clica (ultimo item da tree)

    Com duplo clique fecha o form e lanca no outro form os dados da operacao desejada, fechando o form de pesquisa.

    O fato é que preciso das informacoes do item clicado em cada nó.. ocorre que se o usuario clicar no (+) a lista expande e nao é preenchido a caixa texto...
    Entao se ele expandir a arvore pelo + da lista, e clicar apenas no texto do ultimo nó... as descricoes dos nós anteriores nao sao preenchidas.

    [Resolvido]Tree View (Adicionar terceiro nó em controle) TreeView1
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 5/6/2012, 21:35

    Olá, Hary

    Não percebi como tens o código completo. É melhor trabalharmos numa base sólida, por isso, é melhor disponibilizar a parte da bd.
    Abraço,
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 5/6/2012, 21:44

    Boas Alexandre... Resolvi assim:

    Utilizei uma Sql com as tres tabelas envolvidas, filtrando a mesma pelo valor do ultimo tag, assim retorna todos os campos referentes a linha.


    '----------------------------
    Sub DisplayForm(I As Integer)
    '----------------------------
    Dim strKey As String
    Dim strTag As String
    Dim StrSQLX As String
    Dim strFilter As String
    Dim Rs As DAO.Recordset
    Dim db As DAO.Database

    Set db = CurrentDb

    ' Pega a chave do nó selecionado
    strKey = Me.myTreeView.SelectedItem.Key
    ' .. em seguida, obtem a propriedade do tag do nó
    'strTag = Nz(Me.myTreeView.Nodes(strKey).Tag, "")
    strTag = Me.myTreeView.Nodes(strKey).Tag
    ' .. then if there is a tag value
    If Len(strTag) >= 0 Then
    'Obtem a letra do tag
    Select Case Left(strKey, 1)

    'Executa a operação conforme o nó selecionado de acordo com o valor do tag
    Case "A"
    Me.txtIdConta = DLookup("ID_Conta", "Conta", "Id_Conta =" & Mid(strKey, 2, 4))
    Me.txtConta = DLookup("PlanoConta", "Conta", "Id_Conta =" & Mid(strKey, 2, 4))

    Case "C"
    Me.txtIDTipo = strTag
    Me.txtTipo = DLookup("TipoConta", "ContaDetalhes", "ID_Detalhes =" & strTag)

    Case "E"
    StrSQLX = "SELECT Conta.ID_Conta, Conta.PlanoConta, ContaDetalhes.ID_Detalhes, ContaDetalhes.TipoConta," _
    & "ContaDetalhesSub.ID_DetalhesSub, ContaDetalhesSub.Descricao" _
    & " FROM Conta INNER JOIN (ContaDetalhes INNER JOIN ContaDetalhesSub ON ContaDetalhes.ID_Detalhes = ContaDetalhesSub.ID_Detalhes) ON Conta.ID_Conta = ContaDetalhes.ID_Conta" _
    & " WHERE ContaDetalhesSub.ID_DetalhesSub =" & strTag & ";"

    Set Rs = CurrentDb.OpenRecordset(StrSQLX)

    Me.txtIdConta = Rs!ID_conta
    Me.txtConta = Rs!TipoConta
    Me.txtIDTipo = Rs!ID_Detalhes
    Me.txtTipo = Rs!TipoConta
    Me.txtIDDesc = Rs!ID_DetalhesSub
    Me.txtDescricao = Rs!Descricao
    End Select
    End If
    End Sub



    Cumprimentos.
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 6/6/2012, 00:03

    Boas Lupercio..Fico grato pelas lisonjas!

    Abraços.
    avatar
    Convidad
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidad 6/6/2012, 00:27


    Nosso amigo "irmão" Lupércio é o Rei do Elogio no fórum.

    Sempre valorizando os colegas. Gente fina!

    Abração!

    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8449
    Registrado : 05/11/2009

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Alexandre Neves 6/6/2012, 08:21

    Bom dia a todos

    Obrigado pelos encómios. Quase me deixam embaraçado, tendo em conta que existem duas dificuldades diferentes das dúvidas: a real e a aparente, e esta foi relativamente simples apenas exigindo paciência.
    Obrigado
    Lupércio
    Lupércio
    VIP
    VIP


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 1143
    Registrado : 07/05/2011

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Lupércio 6/6/2012, 13:29

    Very Happy Very Happy Bom dia á todos!
    É o minino que posso fazer, e confesso que tenho aprendido e muito, mas muito mesmo com os Senhores. Eu sou apaixonado por Access, e aqui encontrei algo que me da mais prazer ainda, porque fico acompanhando os tópicos, e testando os códigos, e quando posso ajudar, ajudo tambem, e vejo a humildade de pessoas que sabe muito, mas muito mesmo, solicitando ajuda, é por isso que são fenômenos em desenvolvimento! Um dia chego lá, Laughing Laughing

    Abraços!
    avatar
    Convidado
    Convidado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Convidado 6/6/2012, 13:47

    Ufa!!!...

    Bem, terminado o trabalho fim deste tópico, atualizei o exemplo na sala de repositórios.

    Creio que ficou muito legal.

    Trata-se de controle de caixa utilizando treewView e outras funcionalidades.

    Espero que gostem.


    http://maximoaccess.forumeiros.com/t2261-controle-caixa-atualizado-com-utilizacao-de-treeview-inclusao-de-grupos-e-sub-grupos-e-pesquisa-em-na-tree


    Abraços a todos.
    mfmaiafilho
    mfmaiafilho
    Avançado
    Avançado


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 410
    Registrado : 02/08/2018

    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  mfmaiafilho 7/5/2021, 00:15

    Olá Hary, poderia disponibilizar o exemplo o link está quebrado...

    Conteúdo patrocinado


    [Resolvido]Tree View (Adicionar terceiro nó em controle) Empty Re: [Resolvido]Tree View (Adicionar terceiro nó em controle)

    Mensagem  Conteúdo patrocinado


      Data/hora atual: 19/4/2024, 06:59