473,473 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MPT Tree for Access

Mark Johnson wrote in:
http://groups.google.com/groups?hl=e...u7n3%404ax.com
but, for example, with the Celko version, if you don't
include the conditionals that I included in the examples I posted then
you could add multiple nodes at the highest level - only implying a
superior root node, which doesn't exist.


Mark, where exactly in your code are the conditionals that need to be
removed for the case mentioned above? - multiple nodes at the highest
level. Some of us need these things spelled out. Thanks.

Jacob

Your Code:

Private Const MPT2_SubLast = 1
Private Const MPT2_SubFirst = 2
Private Const MPT2_InsertAfter = 3
Private Const MPT2_InsertBefore = 4
' Called by a cover function which supplies the name for new node,
' the name of the reference node, and the insertion mode
Private Sub sMPTTadd(strNew As String, strRef As String, ByVal
bytWhere As Byte)

Dim varRead As Variant, lngLftPivot As Long, lngRgtPivot As Long,
lngNewLft As Long

varRead = DLookup("lngR", "mpttTest", "txCategory='" & strRef &
"'")
If IsNull(varRead) Then
lngRgtPivot = IIf(fGetThisDB.OpenRecordset("SELECT Count(*)
FROM mpttTest")(0) > 0, DLookup("lngR", "mpttTest", "lngL=1"), 1)
bytWhere = MPT2_SubLast
Else
lngRgtPivot = varRead
varRead = DLookup("lngL", "mpttTest", "txCategory='" & strRef
& "'")
If varRead = 1 Then bytWhere = MPT2_SubLast
End If

lngLftPivot = lngRgtPivot
lngNewLft = lngRgtPivot

Select Case bytWhere
Case MPT2_SubLast
lngRgtPivot = lngRgtPivot - 1
Case MPT2_SubFirst
lngLftPivot = varRead
lngRgtPivot = lngLftPivot
lngNewLft = lngLftPivot + 1
Case MPT2_InsertBefore
lngNewLft = varRead
lngLftPivot = lngNewLft - 1
lngRgtPivot = lngLftPivot
Case MPT2_InsertAfter
lngNewLft = lngNewLft + 1
End Select

fGetThisDB.Execute "UPDATE mpttTest SET lngL = iif(lngL > " &
lngLftPivot & ", lngL + 2, lngL)," & _
" lngR = iif(lngR > " &
lngRgtPivot & ", lngR + 2, lngR)"

fGetThisDB.Execute "INSERT INTO mpttTest (txCategory, lngL, lngR)
VALUES ('" & strNew & "'," & lngNewLft & "," & lngNewLft + 1 & ")"

End Sub
Nov 12 '05 #1
0 1208

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: utku | last post by:
I am studying on a project that requires to manipulate the index data. I know oracle uses b-tree index as the default structure.. But where is this structure stored? Is it a table. If so, can I...
14
by: Dave | last post by:
Hello all, After perusing the Standard, I believe it is true to say that once you insert an element into a std::list<>, its location in memory never changes. This makes a std::list<> ideal for...
7
by: Casper | last post by:
In scanning a drive and comparing file content, I need to remember filepaths to every single file I encounter so I can take actions on certain files later on. Rather than having a huge list...
1
by: WindAndWaves | last post by:
Hi Gurus Most of you will be aware of the use of a tree view type menu/control that is used in windows explorer, the windows start button, register editor, etc.... etc.... It allows you to...
1
by: Daniel Bass | last post by:
Using VC#.Net, I want to take a statement, that loosely follows the rules of an SQL'a "WHERE" statement, and determine whether that statement is true or false. For example: ( ( Head = 'abc')...
4
by: Ken | last post by:
I have a binary tree in VB NET and insertions seem to be slow. The program receives data from one source and inserts it into the tree. The program receives data from another source and...
4
by: negative | last post by:
Dear all, I want to create a tree, where every node has an undetermined number of children (during the population of the tree, the exact number of children of each node , will become clear). So...
1
by: David Hirschfield | last post by:
I've written a tree-like data structure that stores arbitrary python objects. The objective was for the tree structure to allow any number of children per node, and any number of root nodes...and...
15
lwwhite
by: lwwhite | last post by:
I'm not sure if this discussion is a better fit for the Access or XML forum and I don't want to double-post, so I'm starting in Access because you've been so helpful to me here. I am preparing a...
1
by: Christopher | last post by:
I hate to start from scratch as the need for it isn't as great as the work it would take. But, it sure would be nice if I had some data structure that represented a generic tree. I heard using...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.