Re: Syntax Error



Yes, two things: Firstly, you're feeding a string value to the OpenReport
method, when it expects an SQL clause. Remove the single quotes from the
clause. Secondly, you should specify # to indicate a literal date.

strWhere = "[dteInvoiceDate] = #" & Me.txtSpecificDate & "#"

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

"CK" <CK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1555F557-9356-4A7F-AE8D-DAB7E392B52E@xxxxxxxxxxxxxxxx
>I have a form where a user can enter the date so that a list of invoices
> meeting that date will be printed. My code looks like this:
>
> Dim strWhere As String
> strWhere = "'[dteInvoiceDate]=" & Me.txtSpecificDate '"
> DoCmd.OpenReport "rptInvoiceListByDate", acPreview, , strWhere
>
> However I get a Syntax error in string in expression. Is there something
> wrong with the code? Thanks.
> ck


.



Relevant Pages

  • RE: Creating a search string based on selections
    ... Dim strWhere As String ... with single quotes, if there numeric fields then the single quotes should be ... the required criteria based on the selections the user name. ...
    (microsoft.public.access.formscoding)
  • Re: Syntax Error
    ... "Graham R Seach" wrote: ... when it expects an SQL clause. ... >> Dim strWhere As String ...
    (microsoft.public.access.forms)
  • Re: Multi options
    ... Dim strWhere As String ... MsgBox "Please enter a start and end date to run this report." ... Dim stDocName As String ... Dim strWhere As Integer ...
    (microsoft.public.access.formscoding)
  • Re: Multi options
    ... Doug Steele, Microsoft Access MVP ... It's only reading in one String once I get this one under ... Dim stDocName As String ... Dim strWhere As String ...
    (microsoft.public.access.formscoding)
  • Re: Multi options
    ... Dim stDocName As String ... Dim strWhere As String ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.formscoding)

Loading