Results 1 to 3 of 3
  1. #1
    PATRICKPBME is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    171

    How do I set up and "either/or" query parameter?

    I have a button on my form that lets me generate a report on a contact for a physician by typing in the physician name when prompted. Some physicians have more than one contract so I want to have the option of either entering the name or the contract number.



    Currently, the query has the criterion of [Enter Name] when it is run. I thought if I entered [Enter Contract # - Optional] in the contract field on the "or" line this would allow me to search either way. I have tried putting the parameters on different lines but as yet have not found the right combination, assuming this can be done.

    I am also looking into how a drop down box might be incorporated for a search as that would alleviate the need for several different buttons. That option remains on the upward side of my learning curve.

    Thanks in advance.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    in a continuous form youd have it show all physician and contracts.
    in the form header put 2 unbound combo boxes: cboDr, cboContract
    the user can do 1 or the other or both. (tho you dont need Dr, if you have Contract)

    but a FIND button on the header too, then the CLICK event of this button will filter the data:

    Code:
    '----------------
    sub btnFilter_click()
    '----------------
    dim sWhere as string 
    
    sWhere = "1=1"
    if not IsNUll(cboDr) then sWhere = sWhere & " and [phsician]='" & cboDr & "'"
    if not IsNUll(cboContract) then sWhere = sWhere & " and [Contract]='" & cboContract & "'"
    
    If sWhere = "1=1" Then
      Me.FilterOn = False
    Else
      Me.Filter = sWhere
      Me.FilterOn = True
    End If
    end sub

  3. #3
    PATRICKPBME is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    171
    Thank you!!!

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

Similar Threads

  1. Replies: 5
    Last Post: 05-06-2016, 11:43 AM
  2. Replies: 6
    Last Post: 12-22-2015, 09:49 PM
  3. Replies: 8
    Last Post: 08-13-2015, 11:08 AM
  4. Replies: 1
    Last Post: 07-21-2015, 03:38 PM
  5. Replies: 8
    Last Post: 07-15-2014, 05:56 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