Please help with this code

  • Thread starter Thread starter EiEiO
  • Start date Start date
E

EiEiO

I'm pulling my hair our...


Table Name=Excel
Form = freports


I am trying to run a Select statement from the Excel table where the
datareceived date is between (and including ) the dates on my freports
form... Can anyone tell me what I am missing here.


......" From Excel " & _
"HAVING (((Excel.DataReceived)>=[forms]![freports]![from]&
And([Excel.DataReceived)<=[forms]![freports]![thru])))"


TIA
 
I'm pulling my hair our...


Table Name=Excel
Form = freports


I am trying to run a Select statement from the Excel table where the
datareceived date is between (and including ) the dates on my freports
form... Can anyone tell me what I am missing here.


....." From Excel " & _
"HAVING (((Excel.DataReceived)>=[forms]![freports]![from]&
And([Excel.DataReceived)<=[forms]![freports]![thru])))"


TIA

What's the context here? Is this building a query in VBA? If so, try
concatenating (and formatting) the values from the form. I'd also
strongly suggest using the WHERE clause (which applies the filter
before doing the sums) rather than HAVING (which sums all the records
in the table and then throws away those which don't match):

..... & " From [EXCEL] " & _
"WHERE Excel.DataReceived>= #" & _
Format(CDate([forms]![freports]![from]),"mm/dd/yyyy") & _
& "# AND [Excel].[DataReceived] <= #" & _
Format(CDate([forms]![freports]![thru]),"mm/dd/yyyy") & "#"


John W. Vinson[MVP]
 
First, you should change the name of the table from Excel, if you have
reference to Microsoft Excel, excel will become a resurved name in access,
but as long that you put it in square brackets it will be fine

Try this
HAVING [Excel].DataReceived>=[forms]![freports]![from]
And [Excel].DataReceived<=[forms]![freports]![thru]
 
Back
Top