Foros del Web » Programación para mayores de 30 ;) » Programación General »

ayuda con treeview en access 2007

Estas en el tema de ayuda con treeview en access 2007 en el foro de Programación General en Foros del Web. Hola amigos como estan, les cuento necesito un poco de ayuda con un treeview en access 2007 y necesito que la estructura del menu me ...
  #1 (permalink)  
Antiguo 02/05/2010, 21:59
 
Fecha de Ingreso: marzo-2002
Mensajes: 99
Antigüedad: 22 años, 1 mes
Puntos: 0
ayuda con treeview en access 2007

Hola amigos como estan, les cuento necesito un poco de ayuda con un treeview en access 2007 y necesito que la estructura del menu me quede asi:

padre1
hijo1
hijo2
padre2
hijo3
hijo4
hijo5
padre3
hijo6
hijo7

es decir que el treeview se habra en 3 niveles y no se como hacer eso...nunca lo he hecho...
este es mi codigo, si he investigado, pero cuando voy a generar el hijo5 que depende del hijo4 y este depende del padre2, a ese nivel del hijo5 no puedo, me da error el codigo, estoy ocupando el control activex de access

Le copio el codigo, se cae en la parte en rojo....

Dim rst As DAO.Recordset, _
strSQL As String

On Error GoTo Form_Load_TratamientoErrores

'AjustarTamaño Me

' vacio el treeview
Me.tvwCategorias.Nodes.Clear
' añado las categorias
strSQL = "SELECT IdCategoria, NombreCategoria, Descripcion"
strSQL = strSQL & " FROM Categorias "
strSQL = strSQL & " ORDER BY NombreCategoria"

' construyo el arbol con las categorias
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)

If Not rst.EOF And Not rst.BOF Then
Do While Not rst.EOF
Me.tvwCategorias.Nodes.Add , , "C" & rst!IdCategoria, rst!NombreCategoria
Me.tvwCategorias.Nodes("C" & rst!IdCategoria).Tag = "IdCategoria = " & rst!IdCategoria
Me.tvwCategorias.Font.Size = 9
Me.tvwCategorias.Font.Bold = True
rst.MoveNext
Loop
End If
rst.Close

strSQL = "SELECT IdSubCategoria, IdCategoria, NombreSubCategoria"
strSQL = strSQL & " FROM SubCategorias"

' añado las subcategorias
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)

If Not rst.EOF And Not rst.BOF Then
Do While Not rst.EOF
Me.tvwCategorias.Nodes.Add "C" & rst!IdCategoria, tvwChild, "CS" & rst!IdSubCategoria, rst!NombreSubCategoria
Me.tvwCategorias.Nodes("CS" & rst!IdSubCategoria).Tag = "IdSubCategoria = " & rst!IdSubCategoria
Me.tvwCategorias.Font.Size = 9
Me.tvwCategorias.Font.Bold = True
rst.MoveNext
Loop
End If
rst.Close

strSQL = "SELECT Categorias.IdCategoria, SubCategorias.IdSubCategoria, Productos.Periodo"
strSQL = strSQL & " FROM (Categorias INNER JOIN Productos ON Categorias.IdCategoria = Productos.IdCategoria) INNER JOIN SubCategorias ON (SubCategorias.IdSubCategoria = Productos.IdSubCategoria) AND (Categorias.IdCategoria = SubCategorias.IdCategoria)"
strSQL = strSQL & " GROUP BY Categorias.IdCategoria, SubCategorias.IdSubCategoria, Productos.Periodo"
strSQL = strSQL & " ORDER BY Categorias.IdCategoria, SubCategorias.IdSubCategoria, Productos.Periodo;"

' añado los periodos de la subcategoria
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)

If Not rst.EOF And Not rst.BOF Then
Do While Not rst.EOF
Me.tvwCategorias.Nodes.Add "CS" & rst!IdSubCategoria, tvwChild, "CSP" & rst!Periodo
Me.tvwCategorias.Nodes("CSP" & rst!IdSubCategoria).Tag = "IdSubCategoria = " & rst!IdSubCategoria
Me.tvwCategorias.Font.Size = 9
Me.tvwCategorias.Font.Bold = True
rst.MoveNext
Loop
End If


' selecciono el primer registro
Set Me.tvwCategorias.SelectedItem = Me.tvwCategorias.Nodes("C1")

' sincronizo el subformulario con la selección del treeview para mostrar los productos de esa categoria
tvwCategorias_NodeClick (Me.tvwCategorias.Nodes("C1"))
Me.imgImagen.Picture = CurrentProject.Path & "\Imagenes\" & DLookup("Imagen", "Categorias", "IDCategoria = 1")
Me.tvwCategorias.SetFocus


Form_Load_Salir:
CierraRecordsetDAO rst
On Error GoTo 0
Exit Sub

Form_Load_TratamientoErrores:
MsgBox "Error " & Err & " en proc.: Form_Load de Documento VBA: Form_frmCatalogo (" & Err.Description & ")", vbCritical + vbOKOnly, "ATENCION"
Resume Form_Load_Salir



de ante mano gracias

Etiquetas: access, treeview
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:29.