+ Reply to Thread
Results 1 to 17 of 17

Access Template Contact Management Database

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-23-2009
    Location
    IOWA
    MS-Off Ver
    2010 Professional
    Posts
    270

    Re: Access Template Contact Management Database

    Go to design view
    Click on cmdGo button
    On Property Sheet go to events tab
    Click the dropdown menu on on click
    Select Event Procedure

    insert the following:
    Private Sub cmdGo_Click()
        Dim strSearch As String
        Dim strFilter As String
        
    On Error GoTo cmdGo_Click_Err
    
        If IsNull(Me.SearchBox) Then
            ' Clear Filter when search box empty
            DoCmd.RunCommand acCmdRemoveFilterSort
            Me.cmdShowAll.Enabled = False
            GoTo cmdGo_Click_Exit
        End If
        
        ' Handle "'s in search
        strSearch = Replace(Me.SearchBox, """", """""")
        
        ' Build the Filter
        strFilter = "([Contact Name] Like ""*" & strSearch & "*"")"
        strFilter = strFilter & " OR ([Hospital / Clinic Name (Arabic)] Like "" * " & strSearch & " * "" )"
        strFilter = strFilter & " OR ([Hospital / Clinic Name (English)] Like "" * " & strSearch & " * "" )"
        DoCmd.ApplyFilter "", strFilter
        Me.cmdShowAll.Enabled = True
    
    cmdGo_Click_Exit:
        Exit Sub
    
    cmdGo_Click_Err:
        MsgBox Error$
        Resume cmdGo_Click_Exit
    
    End Sub
    Repeat the top except instead of clicking the on click, click On Got Focus

    Private Sub cmdGo_GotFocus()
        Call cmdGo_Click
    End Sub
    That will make it so if you hit tab or enter when you are done typing it will apply the filter.

    Hope this helps,

    Dan
    Last edited by split_atom18; 03-29-2012 at 02:26 PM. Reason: Fixed Error In Code
    "I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
    If my advice has been helpful to you, then please help me by clicking on the "Star" and adding to my reputation, Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1