Results 1 to 9 of 9
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SQL AND statement (MSACESS2003)

    As posted, you seem to be trying to add the same condition twice. That doesn't make sense. So please explain more clearly what you want to accomplish.

  2. #2
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL AND statement (MSACESS2003)

    Sorry Hans, cut and pasted too quickly, I have just corrected my post, thanks

  3. #3
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL AND statement (MSACESS2003)

    I am trying to add an add line to a where statement. I have modified the first part, however if I start with an AND statement it fails.

    MySql = MySql & " WHERE SubDirectoryDocs.ID2=" & [Forms]![Docsfilter].[Form].Label101.Caption

    'AND '((SubDirectoryDocs.IDD2)=[forms]![Docsfilter].[form].[label102].[caption]));

    Many thanks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SQL AND statement (MSACESS2003)

    It still doesn't make sense. Both conditions are for SubDirectoryDocs.ID2. ID2 can't be two different values at the same time.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL AND statement (MSACESS2003)

    Sorry Hans, I corrected it again as you were answering, as I realised the mistake. Thought I would be honest and tell you so you did not think you misread it. Regards

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SQL AND statement (MSACESS2003)

    MySql is a string, you have to concatenate the new condition just like you concatenate the first condition:
    <code>
    MySql = MySql & " WHERE SubDirectoryDocs.ID2=" & Forms!Docsfilter!Label101.Caption & _
    " AND SubDirectoryDocs.IDD2=" & Forms!Docsfilter!Label102.Caption
    </code>
    By the way, is this code running in the form Docsfilter?

  7. #7
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL AND statement (MSACESS2003)

    Many thanks Hans. Yes it is running on the form Docsfilter at rhe moment so I can check the SQL is correct, however it is to go to my popup form later where there will be an edit on the record.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SQL AND statement (MSACESS2003)

    Leave the code as it is then.

  9. #9
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL AND statement (MSACESS2003)

    Thanks Hans, it's all working well. Thanks for your appreciated help again. Best regards

Posting Permissions

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