01/02/2015, 20:51
firtina
Tüm arkadaşlar iyi akşamlar,
Daha önce öğrenmek istediğim tüm sorularıma anında cevap verildiğinden tüm ilgilenenlere teşekkür ederim. Sitenizde sürekli dolaştığımdan treeview uygulamalı bir örnek gördüm ve çok hoşuma gitti. Çok kullanışlı olacağına inandığım için incelemekteyim.
İki sorum olacak müsaadelerinizle;
1 - Treeview uygulamasında Split Form görüntüsü Form görüntüsü şeklinde çıkmaktadır. Tasarım görünümünde Split Form normal çalışıyor fakat Program çalıştığında form görünümüne geçiyor.
Zannedersem Tables bölümünde bulunan tbl_Switchboard ait kod'a kırmızı olan yere Split Form'a ait bir kod yazmak gerekiyor. Ama siz ustalar daha iyisini bilirsiniz.
Private Sub tvSB_NodeClick(ByVal node As Object)
'User clicked a node
Dim strSwitchboard_SubForm_ToShow As String
Dim strForm_OpenArgs As String
'The default form to be loaded into the subform-area - if no other will be set within this sub
strSwitchboard_SubForm_ToShow = mconMainForm
'Default: no contents for information being pulled from a form loaded into the subform
mstrFormArgs = ""
'This statement should actually never evaluate to false, it's rather meant to further
'describe the usage of the Split()-function
If UBound(Split(node.Key, ";")) = 3 Then
Dim strObjectType As String
Dim strObjectName As String
Dim strObjectAddtnl As String
strObjectType = Split(node.Key, ";")(1) 'second argument within the node's key
strObjectName = Split(node.Key, ";")(2) 'third argument within the node's key
strObjectAddtnl = Split(node.Key, ";")(3) 'fourth argument within the node's key
On Error Resume Next
Select Case strObjectType
Case "Form"
'Just pass on the form's name - this will result in the switchboard's subform
'being set to this form.
strSwitchboard_SubForm_ToShow = strObjectName
mstrFormArgs = strObjectAddtnl
Case "Form_Dialog"
'Load a form separately
DoCmd.OpenForm FormName:=strObjectName, windowmode:=acDialog, OpenArgs:=strObjectAddtnl
Case "Report"
'This is just a sample call to a report - you might want to distinguish
'between printing directly or showing the preview here.
DoCmd.OpenReport reportname:=strObjectName ', OpenArgs:=strObjectAddtnl '<-- OpenArgs are possible for reports starting with Access 2002 only!
Case "Code"
'For the sake of the sample, this call references a sub within the switchboard-form's
'module (hence the CodeContextObject - this could as well be <Me>).
'An alternative would be to call a function within a general module - in order to do so,
'you'll have to know that module's name (or index). The call would then look like this:
' CallByName modules(0), strObjectName, VbMethod
'or
' CallByName modules("mdl_SomeModule"), strObjectName, VbMethod
CallByName CodeContextObject, strObjectName, VbMethod, strObjectAddtnl
Case ""
'do nothing (user clicked a parent-node)
Case Else
'Unrecognized "Ojbect-Type" - show an error-message
MsgBox "Unknown Object-Type within Switchboard-table: " & strObjectType, vbExclamation, "Error"
End Select
End If
If Me!Switchboard_Subform.SourceObject <> strSwitchboard_SubForm_ToShow Then
'If this sub resulted in a different form to be shown in the subform-area, load it
Me!Switchboard_Subform.SourceObject = strSwitchboard_SubForm_ToShow
End If
If Err.Number <> 0 Then
'For debugging-purposes, I suggest adding a message like this.
'
'For the sample, I'm only providing one form
MsgBox "This would result in a " & strObjectType & " called " & Q & strObjectName & Q & " being called," & vbCrLf & _
"but calling the object raised an exception (that object probably just doesn't exist).", _
vbInformation, "Error/bug: (Node-click)"
End If
If strSwitchboard_SubForm_ToShow <> mconMainForm Then
'Attempt to have a potentially loaded form refresh its information;
'In order for this to be successful, the subform will have to provide a public sub called "RefreshInfo"
Err.Clear
Switchboard_Subform.Form.RefreshInfo
End If
End Sub
2 - Bu uygulamada üste bulunan menuleri gizlemek mümkün müdür?
Sorularım çok uzun oldu kusuruma bakmayım. Konuyla ilgilenenlere şimdiden teşekkür ederim.
Daha önce öğrenmek istediğim tüm sorularıma anında cevap verildiğinden tüm ilgilenenlere teşekkür ederim. Sitenizde sürekli dolaştığımdan treeview uygulamalı bir örnek gördüm ve çok hoşuma gitti. Çok kullanışlı olacağına inandığım için incelemekteyim.
İki sorum olacak müsaadelerinizle;
1 - Treeview uygulamasında Split Form görüntüsü Form görüntüsü şeklinde çıkmaktadır. Tasarım görünümünde Split Form normal çalışıyor fakat Program çalıştığında form görünümüne geçiyor.
Zannedersem Tables bölümünde bulunan tbl_Switchboard ait kod'a kırmızı olan yere Split Form'a ait bir kod yazmak gerekiyor. Ama siz ustalar daha iyisini bilirsiniz.
Private Sub tvSB_NodeClick(ByVal node As Object)
'User clicked a node
Dim strSwitchboard_SubForm_ToShow As String
Dim strForm_OpenArgs As String
'The default form to be loaded into the subform-area - if no other will be set within this sub
strSwitchboard_SubForm_ToShow = mconMainForm
'Default: no contents for information being pulled from a form loaded into the subform
mstrFormArgs = ""
'This statement should actually never evaluate to false, it's rather meant to further
'describe the usage of the Split()-function
If UBound(Split(node.Key, ";")) = 3 Then
Dim strObjectType As String
Dim strObjectName As String
Dim strObjectAddtnl As String
strObjectType = Split(node.Key, ";")(1) 'second argument within the node's key
strObjectName = Split(node.Key, ";")(2) 'third argument within the node's key
strObjectAddtnl = Split(node.Key, ";")(3) 'fourth argument within the node's key
On Error Resume Next
Select Case strObjectType
Case "Form"
'Just pass on the form's name - this will result in the switchboard's subform
'being set to this form.
strSwitchboard_SubForm_ToShow = strObjectName
mstrFormArgs = strObjectAddtnl
Case "Form_Dialog"
'Load a form separately
DoCmd.OpenForm FormName:=strObjectName, windowmode:=acDialog, OpenArgs:=strObjectAddtnl
Case "Report"
'This is just a sample call to a report - you might want to distinguish
'between printing directly or showing the preview here.
DoCmd.OpenReport reportname:=strObjectName ', OpenArgs:=strObjectAddtnl '<-- OpenArgs are possible for reports starting with Access 2002 only!
Case "Code"
'For the sake of the sample, this call references a sub within the switchboard-form's
'module (hence the CodeContextObject - this could as well be <Me>).
'An alternative would be to call a function within a general module - in order to do so,
'you'll have to know that module's name (or index). The call would then look like this:
' CallByName modules(0), strObjectName, VbMethod
'or
' CallByName modules("mdl_SomeModule"), strObjectName, VbMethod
CallByName CodeContextObject, strObjectName, VbMethod, strObjectAddtnl
Case ""
'do nothing (user clicked a parent-node)
Case Else
'Unrecognized "Ojbect-Type" - show an error-message
MsgBox "Unknown Object-Type within Switchboard-table: " & strObjectType, vbExclamation, "Error"
End Select
End If
If Me!Switchboard_Subform.SourceObject <> strSwitchboard_SubForm_ToShow Then
'If this sub resulted in a different form to be shown in the subform-area, load it
Me!Switchboard_Subform.SourceObject = strSwitchboard_SubForm_ToShow
End If
If Err.Number <> 0 Then
'For debugging-purposes, I suggest adding a message like this.
'
'For the sample, I'm only providing one form
MsgBox "This would result in a " & strObjectType & " called " & Q & strObjectName & Q & " being called," & vbCrLf & _
"but calling the object raised an exception (that object probably just doesn't exist).", _
vbInformation, "Error/bug: (Node-click)"
End If
If strSwitchboard_SubForm_ToShow <> mconMainForm Then
'Attempt to have a potentially loaded form refresh its information;
'In order for this to be successful, the subform will have to provide a public sub called "RefreshInfo"
Err.Clear
Switchboard_Subform.Form.RefreshInfo
End If
End Sub
2 - Bu uygulamada üste bulunan menuleri gizlemek mümkün müdür?
Sorularım çok uzun oldu kusuruma bakmayım. Konuyla ilgilenenlere şimdiden teşekkür ederim.