Filtering Sub Form

R

ramon

hi all,

I want to Open a subform (sfrmDetails) using the NodeClick
event of a Tree View Control in another form (frmOrder)
The TreeViewControl has three levels. First the parent
node is the OrderNo., the child is the PersonResponsible
and the grandChild is the OrderDate.
My problem is in the NodeClick event, if I click on the
OfferNo the subform is displayed correctly because of my
filter definition. The problem is that I don't know how to
define the filter in order that either the OrderNo,
PersonResponsible or OrderDate is clicked the subForm for
the corresponding OrderID should be displayed.
So can you help me please:
a. Creating nodes that show the OrderNo, PersonResponsible
and OrderDate and hides the OrderId but that I can pick
this OrderID for the filter.
b. Define a filter in order to Open sfrmDetails displaying
the right info no matter if the user clicked on the
OrderNo, PersonResponsible or OrderDate
c. suggestions??

I aid with a code found in the knowledge base. The code
looks like this:
=================CODE==================
On Error GoTo errAddBranch
Dim nodCurrent As Node
Dim objTree As TreeView
Dim strCriteria As String
Dim strText As String
Dim strKey As String
Dim nodChild As Node


Set objTree = Me!xTree.Object


rst.Sort = "OfferDate ASC"
rst.MoveFirst
Do Until rst.EOF

strText = rst(strTextField)
strKey = "a" & rst(strIDField)
Set nodCurrent = objTree.Nodes.Add(, , strKey, strText)
Set nodChild = objTree.Nodes.Add(nodCurrent,
tvwChild, , rst(LastName))
Set nodCurrent = nodChild
Set nodChild = objTree.Nodes.Add(nodCurrent,
tvwChild, , rst(varOrderDate))
rst.MoveNext
Loop
exitAddBranch:
Exit Sub
errAddBranch:
MsgBox Err.Number & " " & Err.Description,
vbCritical, "TreeCtl Error:"
Resume exitAddBranch
End Sub
==============END CODE======================

And for the NodeClick Event:
===========BEGIN CODE=======================
Private Sub xTree_NodeClick(ByVal Node As Object)
Dim strSQL As String
strSQL = "OrderNo Like " & Node
DoCmd.OpenForm "sfrmTreeData", acNormal, , strSQL
End Sub
========================END CODE =================

thx
 
L

Larry Linson

First of all, I don't understand the use of a TreeView for data that isn't
heirarchical in nature, and the items you describe are not. That is the only
purpose for a Tree View.

If you display the information in a simple form... since they are all
characteristics of the Order... then it is trivial... you just use the
OrderID of the Current Record.

Also, you will simplify deployment of your application because you won't
have an extra ActiveX control to distribute and register.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

no one is helping... 2
Unique Key in Treeview 2
Treeview 4
Challenging Recordset 1
Problem with Tree View 2
Problem with Treeview code 3
Oracle returning wrong datatype. 0
Need help modifying code 0

Top