Dear All,
I have this function as following. When I apply it in forms, sometimes
the expected subform appears , sometimes not. What could be wrong?
Please help.
Option Compare Database
Option Explicit
Public bolLinkSubForm As Boolean
Public Sub linkSubForm(frm As Form, strSubFormContainer As String, _
strChild As String, strMaster As String, _
Optional strRecSource As String, _
Optional strSubForm As String)
On Error GoTo Fehler
bolLinkSubForm = True
Application.Echo False
If strSubForm = "" Then strSubForm = strSubFormContainer
frm(strSubFormContainer).LinkChildFields = ""
frm(strSubFormContainer).LinkMasterFields = ""
frm(strSubFormContainer).SourceObject = strSubForm
If (strChild <> "" And strMaster <> "") Then
frm(strSubFormContainer).LinkChildFields = strChild
frm(strSubFormContainer).LinkMasterFields = strMaster
End If
If strRecSource <> "" Then
frm(strSubFormContainer).Form.RecordSource = strRecSource
End If
Application.Echo True
bolLinkSubForm = False
Exit Sub
Fehler:
Application.Echo True
Select Case Err.Number
Case 2101
Resume Next
Case Else
MsgBox "Error in linkSubForm: " & vbCr & Err.Description & vbCr & _
" Number: " & Str(Err.Number)
Resume Next
End Select
End Sub
I use the following code in a command button:
linkSubForm Me, "subFrame", "ClientContactID", "ClientContactID", ,
"subContactClient"
Best Regards,
Kevin
Posted by: Kevin <qingqinga@yahoo.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
Tidak ada komentar:
Posting Komentar