Results 1 to 5 of 5

Thread: Query question

  1. #1
    Join Date
    Oct 2002
    Posts
    32

    Question Unanswered: Query question

    Whenever I include an OR in the query, I seem to get everything instead of just the records I want. Is it possible to construct a query that will require matches to 2 or more fields (AND) while at the same time looking for an additional required match in any one of 2 or more other fields (OR)?

    For example, I only want to include matches where Field1 = A, Field2 = B, and (Field3 = C or Field4 = C). Can I do this, and--if so--how?

    Thanks

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    This should work fine - please post your query. Something like - where Field1 = 1 and Field2 = 2 and (Field3 = 3 or Field4 = 3). Is more than 1 table involved ?

  3. #3
    Join Date
    Oct 2002
    Posts
    32
    Thanks, rnealejr. My error. The parentheses were not getting passed with other user-selected values when the query was constructed. Problem resolved.

    Timm

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    And that makes perfect sense with your description of the problem. FYI - You may already do this, but if you have a query (or anything you need to test) that is being dynamically created, first validate that it is what you think it should be - either through a debug tool or spitting it out to the screen or file.

    Good luck.

  5. #5
    Join Date
    Aug 2012
    Posts
    19
    I am facing problem that how to validate Field1, Field2, Field3 in Forms Access 2003
    I can write like this
    Event to write codes I do not know which I need how to do this

    if field1 = 1 then
    statement
    elseif field2 =2 then
    statement
    elseif field3 = 4 then
    statement
    end select
    end if
    How to write code in form Design. Can I write through Load Form or something other
    If I click on Fields1 then the following line appead in Codes
    Private Sub field1_BeforeUpdate(Cancel As Integer)
    which event I have to click in Properties etc

Posting Permissions

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