Results 1 to 3 of 3
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Filter Form by search

    I have a form called "File Search" that contains an unbound textbox called "SrchMed_ID". I have added a button. I would like the button to take the number I enter into "SrchMed_ID" to see if it is present in my form called "File Tracking" (query for this form is "CheckOUT-IN_Input"); if the number I enter is present open to that record in the form other wise open the form on a new record.

    Here is what I have so far it works, except for opening to the number I enter for my search. It opens the form to the first record.
    Thank you for your help.

    Private Sub srchfiles_Click()
    Dim MedID As String
    ' Get Value from Medicaid_ID textbox on the Form:
    Me.srchfiles.SetFocus
    Me.SrchMed_ID.SetFocus


    MedID = Me.SrchMed_ID.Text

    If IsNull(DLookup("Last_Name", "CheckOUT-IN_Input", "Medicaid_ID = '" & SrchMed_ID & "'")) Then
    ' NAME is Null because the Medicaid_ID doesn't exist.

    DoCmd.OpenForm "File Tracking", , , "Medicaid_ID = '" & SrchMed_ID & "'"

    Else
    ' NAME is not Null because the Medicaid_ID does exist.
    DoCmd.OpenForm "File Tracking"



    End If
    End Sub

  2. #2
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    Try This:
    set your control bound to "Medicaid_ID" to default to =[Forms]![File Search]![SrchMed_ID]
    Then try this in you VB

    Private Sub srchfiles_Click()
    Dim MedID As String
    ' Get Value from Medicaid_ID textbox on the Form:
    Me.srchfiles.SetFocus
    Me.SrchMed_ID.SetFocus
    MedID = Me.SrchMed_ID.Text

    If IsNull(DLookup("Last_Name", "CheckOUT-IN_Input", "Medicaid_ID = '" & SrchMed_ID & "'")) Then
    ' NAME is Null because the Medicaid_ID doesn't exist.

    DoCmd.OpenForm "File Tracking", , , "Medicaid_ID = '" & SrchMed_ID
    Else
    ' NAME is not Null because the Medicaid_ID does exist.
    DoCmd.OpenForm "File Tracking", , , , acFormAdd

    End If
    End Sub

    I think that should do it.

  3. #3
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Filter Form by search

    Will this conflict with another search button I have for another form using the same Medicaid_ID field?
    Thanks.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-05-2011, 07:27 AM
  2. Replies: 2
    Last Post: 07-29-2011, 07:46 PM
  3. How to filter/search using a forum?
    By MediaCo in forum Access
    Replies: 3
    Last Post: 07-04-2011, 03:30 AM
  4. Query filter search
    By mseeker22 in forum Queries
    Replies: 6
    Last Post: 06-22-2011, 03:35 PM
  5. Database Search filter
    By dada in forum Programming
    Replies: 7
    Last Post: 08-19-2010, 12:42 AM

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