Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    660

    Unanswered: Same search form, but different record sources

    I have access front end, the user want to search by name and phone, but the search form are same, can i use the same form but different record sources, so far, i just know i need to create two querys, one is for searching by name, another is for searching by phone, but i need to create two same forms. Do you have a way that just create one form, but can be use for search by name and phone. As too many forms is difficulty to maintain, and modify. Thanks.

  2. #2
    Join Date
    Sep 2004
    Posts
    161
    You can have both fields on the same form and modify the query or the criteria on the Openform of the resultant form
    Ex :
    Query = "Select * From table where"
    Query= Query + iif(Name<>"", "Name='" & name & "'","")
    if NumTel<>"" and Name<>"" then
    Query=Query + " and "
    end if
    Query= Query + iif(Numtel<>"", NumTel ='" & Numtel & "'","")

    ResultForm.RecordSource= Query
    oR
    Query= Query + iif(Name<>"", "Name='" & name & "'","")
    if NumTel<>"" and Name<>"" then
    Query=Query + " and "
    end if
    Query= Query + iif(Numtel<>"", NumTel ='" & Numtel & "'","")
    Docmd.Openform "ResultForm",,,Query

Posting Permissions

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