Results 1 to 3 of 3
  1. #1
    jsimard is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    28

    Search A Database


    Is there a way to search an entire database? Almost like a google search where a user could put in a few key words and it would retrieve all records no matter which fields the key words appeared in?

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Yes, here is link that may be what you are looking for. http://www.databasejournal.com/featu...a-Database.htm


    HTH

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Try:

    Code:
    Public Sub ScanAllForText(ByVal pvVal, ByVal pvDataType)
    Dim rst, rst2  'As Recordset
    Dim tdf As TableDef
    Dim sSql As String
    Dim fld As Field
    Dim vDelim, vTyp
    Select Case pvDataType
       Case "T"  'text
         vDelim = "'"
         vTyp = 10
         
       Case "D"  'date
         vDelim = "#"
         vTyp = 8
       
       Case Else  'number
    End Select
    Debug.Print pvVal; " found in: "
    For Each tdf In CurrentDb.TableDefs   'each tbl
      If InStr(tdf.Name, "msys") = 0 Then   'skip sys tables
            Set rst = CurrentDb.OpenRecordset("Select * from [" & tdf.Name & "]")
            With rst
               For Each fld In .Fields    'each fld
                  If fld.Type = vTyp Or vTyp = "" Then
                        sSql = "select [" & fld.Name & "] from [" & tdf.Name & "] where [" & fld.Name & "] = " & vDelim & pvVal & vDelim
                        Set rst2 = CurrentDb.OpenRecordset(sSql)
                        If rst2.RecordCount > 0 Then Debug.Print tdf.Name & "." & fld.Name
                  End If
               Next
            End With
      End If
    Next
    Set rst = Nothing
    Set rst2 = Nothing
    Set tdf = Nothing
    Set fld = Nothing
    MsgBox "done"
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Database Access Search
    By abdullahsikandar in forum Access
    Replies: 8
    Last Post: 05-01-2014, 12:48 PM
  2. Search form database
    By Jan22 in forum Access
    Replies: 4
    Last Post: 11-20-2013, 11:16 AM
  3. How to search the Database?
    By simba in forum Programming
    Replies: 2
    Last Post: 10-21-2010, 05:48 AM
  4. Database Search filter
    By dada in forum Programming
    Replies: 7
    Last Post: 08-19-2010, 12:42 AM
  5. Search a Number in Database Field
    By julia_877 in forum Programming
    Replies: 3
    Last Post: 08-06-2010, 01:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums