Results 1 to 2 of 2
  1. #1
    kabichan is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2008
    Posts
    5

    Question Help with ApplyFilter

    I have two forms, frmJobInfo and frmReportGenerator.
    When the user selects JobNumber(s) from combobox(es) on frmReportGenerator, I want to display frmJobInfo as Datasheet, displays the JobNumber selected by the user.

    E.X.
    frmJobInfo

    JobNumber JobTitle
    -------------------------------------
    0001 Computer Lab Assistant I
    0002 Computer Lab Assistant II
    1001 Office Assistant I
    1002 Office Assistant II
    1003 Office Assistant III

    if the user selects 0001 in combobox 1 and 0005 in combobox 2,
    then frmJobInfo display the following information:

    JobNumber JobTitle
    --------------------------------------
    0001 Computer Lab Assistant I
    1003 Office Assistant III


    ---------------------------------------------------------------
    Here's my code:

    DoCmd.OpenForm "frmJobInfo", acFormDS
    DoCmd.ApplyFilter , _
    "JobNumber like '*" & Me.cboJobNumber.Value & "*' or " & _
    "JobNumber like '*" & Me.cboJobNumber2.Value & "*' "

    ---------------------------------------------------------------
    HOWEVER, MY PROBLEM IS:

    This works only when I select a job number in both comboboxes.
    If I select 0001 in combobox1 and does not select any in combobox2,
    the form does not filter anything, and it display the whole data.



    Sometimes I need to filter every job number that start with a specific number, so I need to keep the "*".

    I really appreciate it if somebody could help me.
    Thank you so much!!
    Kabi

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    I would conditionally build the filter based upon whether one or two fields are being filtered.

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

Similar Threads

  1. Cascaded comboboxes in a form
    By luca in forum Forms
    Replies: 2
    Last Post: 11-22-2009, 05:36 AM
  2. subform comboboxes/Textboxes
    By terryvanduzee in forum Forms
    Replies: 2
    Last Post: 11-19-2009, 07:41 PM
  3. Refreshing comboboxes in a subform
    By KB_Dev in forum Programming
    Replies: 1
    Last Post: 04-07-2009, 12:12 PM
  4. DoCmd.SendObject Help
    By bgreer5050 in forum Programming
    Replies: 0
    Last Post: 01-12-2007, 06:27 PM
  5. Using ApplyFilter in Form...help please
    By playfuljade in forum Forms
    Replies: 8
    Last Post: 12-19-2005, 09:35 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