Public Function FUN_CREATE_TABLE_GROUP_TREEVIEW()
'COMODITY_GROUP_TBL
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
If FUN_IS_TABLE("GROUP_TREEVIEW_TBL") = False Then
GLB_con.Execute "SELECT COMODITY_GROUP_TBL.* INTO [GROUP_TREEVIEW_TBL]" _
& " From COMODITY_GROUP_TBL " _
& "WITH OWNERACCESS OPTION;"
End If
' ОЧИСТКА ПО ЛЮБОМУ -ПЕРЕД ЗАПОЛНЕНИЕМ
FUN_CLEAR_TABLE ("GROUP_TREEVIEW_TBL")
'ПОМЕЩАЕМ ВСЕХ БЕЗ РОДИТЕЛЕЙ
GLB_con.Execute "INSERT INTO GROUP_TREEVIEW_TBL" _
& " SELECT COMODITY_GROUP_TBL.*" _
& " From COMODITY_GROUP_TBL" _
& " Where (((COMODITY_GROUP_TBL.GROUP_PARENT) = ""0"")) Or (((COMODITY_GROUP_TBL.GROUP_PARENT) = """")) Or (((COMODITY_GROUP_TBL.GROUP_PARENT) Is Null))" _
& " WITH OWNERACCESS OPTION;"
'открываем ВСЕХ БЕЗ РОДИТЕЛЕЙ GROUP_TREEVIEW_TBL
'и перебераем с поиском их детей в COMODITY_GROUP_TBL.*
rst.Open "SELECT GROUP_TREEVIEW_TBL.*" _
& " From GROUP_TREEVIEW_TBL" _
& " WITH OWNERACCESS OPTION;", GLB_con, adOpenKeyset, adLockOptimistic
Do Until rst.EOF ' переброс детей "ID_GROUP" в GROUP_TREEVIEW_TBL
GLB_con.Execute "INSERT INTO GROUP_TREEVIEW_TBL" _
& " SELECT COMODITY_GROUP_TBL.*" _
& " From COMODITY_GROUP_TBL" _
& " Where (((COMODITY_GROUP_TBL.GROUP_PARENT) = '" & rst("ID_GROUP") & "'))" _
& " WITH OWNERACCESS OPTION;"
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
End Function
|