thaicosmic.com

หนัง

วันเสาร์ที่ 19 ตุลาคม พ.ศ. 2556

อ้างอิงฟังชั่นในไฟล์ mdb อื่นใน directory เดียวกัน

Function FixUpRefs()
Dim loRef As Access.Reference
Dim intCount As Integer
Dim intX As Integer
Dim blnBroke As Boolean
Dim strPath As String
Dim FoundSpacialRef As Boolean
On Error Resume Next

'Count the number of references in the database
intCount = Access.References.Count

'Loop through each reference in the database
'and determine if the reference is broken.
'If it is broken, remove the Reference and add it back.
FoundSpacialRef = False
For intX = intCount To 1 Step -1
            Set loRef = Access.References(intX)
            With loRef
                        blnBroke = .IsBroken
                        strPath = .FullPath
                        If blnBroke = True Or Err <> 0 Then
                     
                                strPath = .FullPath
                                With Access.References
                                                .Remove loRef
                                                .AddFromFile strPath
                                End With

                        End If
                '===
                        If .Name = "PolngpoleVba" Then
                                    FoundSpacialRef = True
                         End If
                    '===
            End With
Next

If FoundSpacialRef Then
    Access.References.Remove Access.References("PolngpoleVba")
End If
    Access.References.AddFromFile CurrentProject.Path & "\" & "PolngpoleVba.mdb"
 
Set loRef = Nothing

' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
End Function