Results 1 to 4 of 4
  1. #1
    hmcquade is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11

    VBA string with OR expression

    Hi!

    I have a form with a search command button, at present, when clicked it brings up all records for jobs 'In Progress', using the following code:



    Private Sub Search_Click()
    Search_String = "[Status]= 'In Progress'"
    DoCmd.ApplyFilter , Search_String
    End Sub

    I would like this command to also bring up all jobs 'On Hold' as well as those 'In Progress', but i am having trouble getting the OR expression right.

    This may be really simple, but i have tried a few combinations and just cannot do it! Can someone PLEASE help me!

    Thanks in advance!

  2. #2
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    change your code to:

    Private Sub Search_Click()
    Search_String = "[Status]= 'In Progress' OR [Status] =" & "'On Hold'"
    DoCmd.ApplyFilter , Search_String
    End Sub
    This should solve the problem:

  3. #3
    hmcquade is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11
    thank you very much that worked!!!!

  4. #4
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Glad that it solve the problem, just mark the thread as solved (top right of the thread tools) and mark this thread as solved.

    Thanks!

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

Similar Threads

  1. Setting SQL = string
    By jasonbarnes in forum Programming
    Replies: 7
    Last Post: 02-18-2011, 11:02 AM
  2. Replies: 1
    Last Post: 02-03-2011, 07:41 AM
  3. Formating string
    By Alex Motilal in forum Reports
    Replies: 7
    Last Post: 12-10-2010, 06:09 AM
  4. Using a string to DIM a Recordset
    By ColPat in forum Programming
    Replies: 10
    Last Post: 09-25-2010, 03:53 PM
  5. Replies: 0
    Last Post: 12-05-2005, 04:09 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