Results 1 to 3 of 3
  1. #1
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162

    Whats wrong with this code?

    Hi all,



    Im trying to call an sql command with the following code but I cant quote see why its not working, I realise why its not working due to lack or brackets so I dont suppose someone could explain the brack situation based on my code please? Do you need to add so many, whats the best practices for this?

    Code:
    MySql = MySql & "WHERE (((TimesheetTable.[Task Date]) Between " & sStartApprovalDate & " And " & sEndApprovalDate & " AND (((TimesheetTable.sCostCode) = 'MD-LAB')) OR (((TimesheetTable.sCostCode) = 'MT-LAB')) AND (((TimesheetTable.Approved)=FALSE))"
    Help is very much appreciated - thanks!

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Have you tried running the query from the QBE? Was it successful? If so, then copy your SQL statement fromt he QBE to your VBA code and test it.

  3. #3
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    Thanks, I managed to get it working. The problem with my code was that I had the incorrect content in the criteria.

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

Similar Threads

  1. What's wrong with my code?
    By Dalagrath in forum Forms
    Replies: 11
    Last Post: 05-18-2011, 04:34 PM
  2. Replies: 20
    Last Post: 09-18-2010, 02:31 PM
  3. Replies: 6
    Last Post: 09-01-2010, 03:12 PM
  4. What is wrong with this code?
    By nkenney in forum Forms
    Replies: 2
    Last Post: 11-16-2009, 03:04 PM
  5. Anything wrong with this one line of code?
    By alsoto in forum Reports
    Replies: 3
    Last Post: 07-01-2009, 09:23 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