Kryst51
Singin' in the Hou. Rain
- Local time
- Today, 03:46
- Joined
- Jun 29, 2009
- Messages
- 1,898
Hi all,
I am using an example of a treeview that I obtained on this thread.
I learn by doing, and fixing things as they come up.
In the code for building the tree view is a union query which I modified how I thought it would fit my needs. I start with a query instead of a table for my records.
This query is as follows:
I believe I have worked all the errors out of this.
I then use this as the basis for this UNION query. I haven't worked with union queries before and am getting a "Syntax error in union query." error. Error Number -2147467259. I've googled this and have not found any of the answers helpful.
Here is my current query:
Originally "strBaseQuery" was not surrounded by the perenthesis nor was the "As baseQuery" part of it. But I thought maybe it needed to be dealt with as a nested query, so I googled how to do those in a "FROM" clause and this is what I came up with. Now, the truth is I do not understand how the tree-view stuff works, so maybe I am using it incorrectly.
But my goal is to get the queries working then step through the code to see what it is doing. But I don't even understand this starting point. (Sorry for the rambling).
Any help is appreciated.
I am using an example of a treeview that I obtained on this thread.
I learn by doing, and fixing things as they come up.
In the code for building the tree view is a union query which I modified how I thought it would fit my needs. I start with a query instead of a table for my records.
This query is as follows:
Code:
Dim IssID as Integer
IssID = Nz(Me.pkNCRHeaderID, 0)
strBaseQuery = " SELECT Trim([ErrorCategory])" & _
" AS ErrorCat, Trim([ErrorSubCategory]) AS ErrorSubCat, Trim([ErrorName])" & _
" AS ErrName, tblNCRIssues.pkNCRIssueID, tblNCRIssues.[pkNCRIssueID] AS IssueID" & _
" FROM tblErrorCategories INNER JOIN (tblErrorSubCategories INNER JOIN (tblErrors INNER JOIN tblNCRIssues ON tblErrors.pkErrorID = tblNCRIssues.fkErrorID) ON tblErrorSubCategories.pkErrorSubCategory = tblErrors.fkErrorSubcategoryID) ON tblErrorCategories.pkErrorCategoriesID = tblErrorSubCategories.fkErrorCategoryID" & _
" WHERE (((tblNCRIssues.fkNCRHeaderID) =" & issID & "))" & _
" GROUP BY Trim([ErrorCategory]), Trim([ErrorSubCategory]), Trim([ErrorName]), tblNCRIssues.pkNCRIssueID, tblNCRIssues.[pkNCRIssueID];"
I believe I have worked all the errors out of this.
I then use this as the basis for this UNION query. I haven't worked with union queries before and am getting a "Syntax error in union query." error. Error Number -2147467259. I've googled this and have not found any of the answers helpful.
Here is my current query:
Code:
strSQL = "SELECT BuildKey(IssueID) As NodeKey, ErrorCat As NodeText, BuildKey(0) As BelongsTo" & _
" FROM (strBaseQuery) As BaseQuery" & _
" UNION ALL SELECT BuildKey(IssueID) As NodeKey, ErrorSubCat As NodeText, BuildKey(Nz(ErrorCat,0) As BelongsTo" & _
" FROM (strBaseQuery) As BaseQuery" & _
" UNION ALL SELECT BuildKey(IssueID) As NodeKey, ErrName As NodeText, BuildKey(Nz(ErrorSubCat,0) As BelongsTo" & _
" FROM (strBaseQuery) As BaseQuery" & _
" UNION ALL SELECT TOP 1 BuildKey('<NULL>') As NodeKey, '<Un-Assigned' As NodeText, BuildKey(0) As BelongsTo" & _
" FROM (strBaseQuery) As BaseQuery" & _
" ORDER BY NodeText"
Originally "strBaseQuery" was not surrounded by the perenthesis nor was the "As baseQuery" part of it. But I thought maybe it needed to be dealt with as a nested query, so I googled how to do those in a "FROM" clause and this is what I came up with. Now, the truth is I do not understand how the tree-view stuff works, so maybe I am using it incorrectly.
But my goal is to get the queries working then step through the code to see what it is doing. But I don't even understand this starting point. (Sorry for the rambling).
Any help is appreciated.