搜檢資料庫物件

                  Sub 搜檢資料庫物件()
Dim x As String, v As String, t, Obj
1
x = InputBox("請輸入「關鍵字,種類代號」: 資料表=t;查詢=q;表單=f")
If x = "" Then Exit Sub
If InStr(x, ",") = 0 Then MsgBox "請輸入類名代號: 資料表=t;查詢=q;表單=f": GoTo 1
v = Right(x, 1)
x = Mid(x, 1, Len(x) - 2)
Select Case v
    Case "t"
        t = acTable
        For Each Obj In CurrentData.AllTables
            If Obj.Name Like "*" & x & "*" Then GoSub slt
            'x = Obj.Name
        Next
    Case "q"
        t = acQuery
        For Each Obj In CurrentData.AllQueries
            If Obj.Name Like "*" & x & "*" Then GoSub slt
        Next
    Case "f"
        t = acForm
        For Each Obj In CurrentProject.AllForms
            If Obj.Name Like "*" & x & "*" Then GoSub slt
        Next
End Select
Exit Sub

slt:
    If MsgBox("「" & Obj.Name & "」?", vbQuestion + vbOKCancel) = vbOK Then
        DoCmd.SelectObject t, Obj.Name, True
        Exit Sub
    End If
Return
End Sub