Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2004
    Posts
    16

    Unanswered: What is wrong with this?

    Hi

    Can anyone tell me what is wrong with this?
    Startdate and enddate values are from combo boxes.

    SELECT visits.* FROM visits WHERE (([visits.visitdate] BETWEEN '"#& Me.startdate.Value &#"' AND '"#& Me.EndDate.Value &#"')) AND (([visits.repname])='Peter');

    thanks

    mat

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by funkkube
    Hi
    SELECT visits.* FROM visits WHERE (([visits.visitdate] BETWEEN '"#& Me.startdate.Value &#"' AND '"#& Me.EndDate.Value &#"')) AND (([visits.repname])='Peter');

    mat
    Try

    SELECT visits.* FROM visits WHERE (([visits.visitdate] BETWEEN # " & Me.startdate & " # AND # " & Me.EndDate & " # )) AND (([visits.repname])='Peter');

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I didn't care about baranthes

  4. #4
    Join Date
    Sep 2004
    Posts
    16

    no joy

    Hi
    thanks for your help but still no joy..

  5. #5
    Join Date
    Sep 2004
    Posts
    161
    And with this syntax ?
    SELECT visits.* FROM visits WHERE visits.visitdate BETWEEN #" & Me.startdate.Value & "# AND #" & Me.EndDate.Value & "# AND visits.repname='Peter';

  6. #6
    Join Date
    Nov 2003
    Location
    Sussex, England
    Posts
    404

    General Advice

    Whenever I get a bit of SQL code that doesn't work I put it into a variable, e.g.

    mySQL = "SELECT visits.* FROM visits WHERE visits.visitdate BETWEEN #" & Me.startdate.Value & "# AND #" & Me.EndDate.Value & "# AND visits.repname='Peter';"

    Put a break in the code, use the debug or immediate window to see the code, (print mySQL). highlight it and copy it. Open a new query in SQL view. Past the code and run it. Very often the error is highlighted with a better message than you get in the code.

    Hope this helps.


Posting Permissions

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