Serving the Quantitative Finance Community

 
User avatar
adamcox
Topic Author
Posts: 0
Joined: July 14th, 2002, 3:00 am

HELP - RECURSIVE TREEVIEW CALL

November 10th, 2004, 5:03 am

Can some have a look at the files attached and see what I am doing wrong with this recursive treeview call using DAO in Excel and VBA.Your Feed back is appreciated. many thanksAdam
 
User avatar
Doney
Posts: 0
Joined: June 24th, 2004, 7:14 am

HELP - RECURSIVE TREEVIEW CALL

November 10th, 2004, 8:29 am

OK, I've got in working with the following:1. Changed the sourcefile location to ThisWorkbook.Path & "\Data (petty I know)2. Dim 'ed objTree as an object (there's probably a better way but I'm lazy)3. Added an rs.MoveFirst before each rs.FindFirst in AddChildren4. changed the FindFirst to this : rs.FindFirst "[ReportsTo] ='" & Mid(Replace(nodBoss.Key, "'", "''"), 2) & "'"which means a) I've wrapped the criteria in single quotes, and b) doubled up any single quotes. Haven't tested the second bit, but not doing it means you'll run into trouble on O'Baoill5. Changed the FindNext in the same wayWorks fine, now
 
User avatar
adamcox
Topic Author
Posts: 0
Joined: July 14th, 2002, 3:00 am

HELP - RECURSIVE TREEVIEW CALL

November 10th, 2004, 11:50 pm

what is the reason for moving to first before find next. The recursive call has to go to the next instance of the first criteria and if not found then returns back. If you put movefirst on every call surely the tree nodes cannot be built.Is your copy working ? If so can you send me the copy so I can see what you have done. My eamil address is adamcox@ozemail.com.authanks for all the effort.cheersadam
 
User avatar
adamcox
Topic Author
Posts: 0
Joined: July 14th, 2002, 3:00 am

HELP - RECURSIVE TREEVIEW CALL

November 11th, 2004, 2:46 am

Okay - update to problem. yes, the recordset must be put to first record so it can scan over all records looking for the field which equals the child node.The major problem also occurred when using DAO, where an apostrophe is encountered. This was the second major reason.thanksadam
 
User avatar
Doney
Posts: 0
Joined: June 24th, 2004, 7:14 am

HELP - RECURSIVE TREEVIEW CALL

November 11th, 2004, 10:46 am

Glad to be of help. You could have got around the .MoveFirst problem by passing the recordset byValue, but that wouldn't be a particularly clever move in terms of efficiency. The apostrophe issue took me back to the good old days of working on Access databases - that's why I've put in the Replace statement - can't guarantee it would work, but I think that's how I used to deal with it.