لدى برنامج أجنبى أقوم بتعديلة ليتناسب مع إحتياجاتى
واجهتنى مشكلتين بالبرنامج
المشكلة الاولى فى ال treeviewcontrol
حيث أننى أريد أن يكون المستوى الثانى فى الفروع هو السلسلة SeriesName و ليس عنوان الكتاب title
و إذا لم تكن هناك سلسلة خاصة بالمؤلف يكون المستوى الثانى هو ال title طبعاً
بمعنى
إذا فرضنا ان مؤلف كالدكتور نبيل فاروق مثلاً ينتج 3 سلاسل ( رجل المستحيل ، ملف المستقبل ، كوكتيل 2000 )
كل منها تحتوى على عدد من الروايات قد تصل إلى 150 رواية
و نجيب محفوظ لا ينتج سلاسل فالكتب الخاصة بة تكون منفصلة ( اللص و الكلاب - رادوبيس - زقاق المدق ...........)
اريد ان يكون ترتيب الشجرة
د / نبيل فاروق
-------------- رجل المستحيل
--------------------------- 1 - العدد الاول
--------------------------- 2 - العدد الثانى
--------------------------- و هكذا
------------- ملف المستقبل
--------------------------- 1 - أشعة الموت
--------------------------- 2 - العدد الثانى
--------------------------- و هكذا
نجيب محفوظ
------------- اللص و الكلاب
------------- رادوبيس
------------- زقاق المدق
و المشكلة هنا فى هذا الكود :
Function tvwBooks_Fill()
‘========================================================
‘Modified from a procedure generated by the Treeview Control Wizard
‘
‘PURPOSE: Fill the ActiveX Treeview Control ‘tvwBooks’
‘ACCEPTS: Nothing
‘RETURNS: Nothing
‘CALLED FROM: Form Load event
‘========================================================
On Error GoTo ErrorHandler
Dim strMessage As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim intVBMsg As Integer
Dim strQuery1 As String
Dim strQuery2 As String
Dim nod As Object
Dim strNode1Text As String
Dim strNode2Text As String
Dim strVisibleText1 As String
Dim strVisibleText2 As String
Set dbs = CurrentDb()
strQuery1 = "qryEBookAuthors"
strQuery2 = "qryEBooksByAuthor"
With Me![tvwBooks]
‘Fill Level 1
Set rst = dbs.OpenRecordset(strQuery1, dbOpenForwardOnly)
‘Add a node object for each record in the "qryEBookAuthors" table/query.
‘For parent nodes, the Key property is based on the the level of the tree
‘in which the node exists and the Link Master field(s) you selected when
‘linking levels in the wizard. For child nodes, the Relative property
‘is based on the level of the tree in which the Parent node exists and
‘the Link Child field(s) you selected when linking levels in the wizard.
Do Until rst.EOF
Debug.Print "Adding Level 1 item: " & rst![AuthorID]
strNode1Text = StrConv("Level1 - " & rst![AuthorID],
vbLowerCase)
Debug.Print "Node 1 text: " & strNode1Text
strVisibleText1 = rst![LastNameFirst]
Debug.Print "Level 1 visible text: " & strVisibleText1
Set nod = .Nodes.Add(Key:=strNode1Text,
Text:=strVisibleText1)
nod.Expanded = True
rst.MoveNext
Loop
rst.Close
‘Fill Level 2
Set rst = dbs.OpenRecordset(strQuery2, dbOpenForwardOnly)
‘Add a node object for each record in the "qryEBooksByAuthor"
‘table/query. For parent nodes, the Key property is based on the
‘level of the tree in which the node exists and the Link Master
‘field(s) you selected when linking levels in the wizard. For child
‘nodes, the Relative property is based on the level of the tree in
‘which the Parent node exists and the Link Child field(s) you selected
‘when linking levels in the wizard.
Do Until rst.EOF
Debug.Print "Adding Level 2 item: " & rst![Title]
strNode1Text = StrConv("Level1 - " & rst![AuthorID], vbLowerCase)
Debug.Print "Node 1 text: "; strNode1Text
strNode2Text = StrConv("Level2 - " & rst![AuthorID] & " - "
& rst![Title], vbLowerCase)
Debug.Print "Node 2 text: " & strNode2Text
strVisibleText2 = rst![Title] & rst![BeenRead]
Debug.Print "Visible text: " & strVisibleText2
.Nodes.Add relative:=strNode1Text,
relationship:=tvwChild,
Key:=strNode2Text,
Text:=strVisibleText2
rst.MoveNext
Loop
rst.Close
End With
dbs.Close
ErrorHandlerExit:
Exit Function
ErrorHandler:
Select Case Err.Number
Case 35601
‘Element not found
strMessage = "Possible Causes: You selected a table/query"
& " for a child level which does not correspond to a value"
& " from its parent level."
intVBMsg = MsgBox(Error$ & strMessage, vbOKOnly +
vbExclamation, "Run-time Error: " & Err.Number)
Case 35602
‘Key is not unique in collection
strMessage = "Possible Causes: You selected a non-unique"
& " field to link levels."
intVBMsg = MsgBox(Error$ & strMessage, vbOKOnly +
vbExclamation, "Run-time Error: " & Err.Number)
Case Else
intVBMsg = MsgBox(Error$ & "@@", vbOKOnly +
vbExclamation, "Run-time Error: " & Err.Number)
End Select
Resume ErrorHandlerExit
End Functionو أثناء بحثى عن حل لهذة المشكلة ، علمت انة كان فى الaccess 97 معالج wizard يقوم بتحرير ال treeview
و إختفى هذا المعالج مع إصدار 2000 و لم يعد مرة ثانية .
لذا فإن البعض يقومون بتصميم الشجرة على access97 ثم يقومون بنسخ الكود ، و لصقة فى الأكسيس xp أو 2003
طبعاً الحصول على نسخة من ال access 97 الان أصبح صعباً
و كذلك مثل هذة العمليات أكبر من قدراتى حتى لو حصلت على الاوفيس 97
و الطلب الثانى بعد أذنكم
هو انة يوجد textbox أسمة file اريد لة زر إستعراض بحيث اربط الtextbox بال path الخاص بملف هذا الكتاب الإكترونى على جهازى
ثم بالضغط على التكست بوكس نفسة ينفتح ملف الكتاب باى صيغة سواء كانت pdf او chm او word
مثل مثال الاستاذ عمار زيد .
ارجو من الجميع الإهتمام بمساعدتى لان البرنامج بالفعل جميل جداً ( على الاقل بالنسبة لى كمبتدئ )
البرنامج بالمرفقات
