|
Private Sub TreeView0_NodeClick(ByVal Node As Object)
Dim strCARGOTYPE_NO As String
Dim strSQL As String
Dim I As Integer
Dim N As Integer
Dim strTip As String
strCARGOTYPE_NO = Right(Node.Key, Len(Node.Key) - 3)
'判断是否是顶层
If strCARGOTYPE_NO = "1" Then '预先定义好的:NO.1,第3位向后的字符,所以是1
strSQL = "SELECT * FROM 产品;"
Me.lblTip.Caption = "产品分类"
Else
I = Len(strCARGOTYPE_NO)
strSQL = "SELECT * FROM 产品 WHERE left([CARGO_TYPE]," & I & ")='" & strCARGOTYPE_NO & "';"
'Debug.Print I
For N = 1 To I / perSectionLong
strTip = strTip & Trim(CurrentDb.OpenRecordset("SELECT CARGOTYPE_NAME FROM 产品分类 where left([CARGOTYPE_NO]," _
& (N * perSectionLong) & ")='" & Left(strCARGOTYPE_NO, (N * perSectionLong)) & "' and CARGOTYPE_LEVEL=" & N & ";")(0).Value) & ">>"
Next
strTip = "产品分类" & ">>" & Left(strTip, Len(strTip) - 2)
Me.lblTip.Caption = strTip
End If
'Debug.Print strSQL
Me.subMX_CARGO.Form.RecordSource = strSQL
End Sub
正在琢磨,上述代码较晕! |
|