Function 作者值搜尋() '檢查強迫參照完整性2015/12/16
Dim t As TableDef, fds As Field, rst As Recordset, flg As Boolean
x = Screen.ActiveControl.SelText
If x = "" Then x = Screen.ActiveControl.Value
For Each t In CurrentDb.TableDefs
For Each fds In t.Fields
If InStr(fds.Name, "作者") Then
Set rst = t.OpenRecordset
With rst
Do Until .EOF
If VBA.StrComp(.Fields(fds.Name).Value, x) = 0 Then
With DoCmd
.OpenTable t.Name
.GoToControl fds.Name
.FindRecord x, acEntire
'.GoToRecord rst.Bookmark
'Exit Function
flg = True
End With
End If
.MoveNext
Loop
End With
End If
Next fds
Next t
If Not flg Then MsgBox "沒找到,可以刪了!", vbExclamation
End Function