Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    41

    Unanswered: Additional "Where"

    Good day,

    I want to make an addition to the statement:

    strsql1 = "Select Count([empid]) as Countofempid from tblvacation where tblvacation.curtour = '" & Me.curtour & "'"

    Basically it will be a where cause like this

    Where tblvaction.vdate = Me.vdate

    Do anyone know if it is possible to add that to the statement above.

    Thanks

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    No problem at all!!

    strsql1 = "Select Count([empid]) as Countofempid from tblvacation where tblvacation.curtour = '" & Me.curtour & "' AND tblvaction.vdate = " & Me.vdate

    Depending on your db engine, you may need to the parse the date with a # or a '. But that's the basic gist. In general, you can always use the reserved words "AND" & "OR" to string conditions together.

  3. #3
    Join Date
    Jul 2003
    Posts
    41
    Hey Teddy,

    Thanks for the reply. I ended up using this statement
    strsql1 = "Select Count([empid]) as Countofempid from tblvacation where tblvacation.curtour = '" & Me.curtour & "' and tblvaction.vdate = #" & Me.txtvdate & "#;"

    But now I get the error:
    "Too few parameters error:Expected 1"

    In this code:

    strsql1 = "Select Count([empid]) as Countofempid from tblvacation where tblvacation.curtour = '" & Me.curtour & "' and tblvaction.vdate = #" & Me.txtvdate & "#;"
    strsql2 = "Select count([empid]) as CountofTourEmps from tblEmployee where tblEmployee.curtour = '" & Me.curtour & "'"
    strsql3 = "Select Count([empid]) as CountofEmpIDF from tblfloater where tblfloater.curtour = '" & Me.curtour & "'"


    Set rs1 = db.OpenRecordset(strsql1) <---Error is here
    Set rs2 = db.OpenRecordset(strsql2)
    Set rs3 = db.OpenRecordset(strsql3)

    Any Ideas?
    I should note that the field txtvdate is Unbound.

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    The only thing in that query I can see that would return a parameter error is the count function. First try commenting out your Set rs1. Make sure it is indeed an issue with the where clause. If it does turn out to definately be the where clause, then pull strsql1 into a debug or a message box so you can see the actual string. Then run the string by itself in a new db window. See what you come up with.

Posting Permissions

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