Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Frustrating Form Coding Error

Geek News

Frustrating Form Coding Error
Scot Dever 12/2/2008 3:48:11 PM
I am trying to create a simple user defined report form for a range of
records between a chosen start and end date but keep getting this compile and
syntax error instead of the report, am I missing something?

Private Sub Command4_Click()

Dim ReportName
ReportName = "Stores Start Order" _
DoCmd.OpenReport _
ReportName:=ReportName, _
view:=acViewPreview, _
WhereCondition:="[StartConstCur]between #"& _
Me.StartDate& "# and #" & _
Me.EndDAte & "#"

End Sub

Re: Frustrating Form Coding Error
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/2/2008 4:01:47 PM
Get rid of the underscore after ReportName = "Stores Start Order". With it
there, you're saying that the following line(s) are part of the same
statement.

You might also want to put a space between the field name and the keyword
between in the WhereCondition.

Private Sub Command4_Click()

Dim ReportName As String

ReportName = "Stores Start Order"

DoCmd.OpenReport _
ReportName:=ReportName, _
view:=acViewPreview, _
WhereCondition:="[StartConstCur] between #"& _
Me.StartDate& "# and #" & _
Me.EndDAte & "#"

End Sub

although to ensure it'll work for all users, regardless of their regional
settings, you'd be better off using

Private Sub Command4_Click()

Dim ReportName As String

ReportName = "Stores Start Order"

DoCmd.OpenReport _
ReportName:=ReportName, _
view:=acViewPreview, _
WhereCondition:="[StartConstCur] between "& _
Format(Me.StartDate, "\#yyyy\-mm\-dd\#") & " and " & _
Format(Me.EndDate, "\#yyyy\-mm\-dd\#")

End Sub

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Scot Dever" <Scot Dever[ at ]discussions.microsoft.com> wrote in message
news:6C48806C-8A3D-4CDE-A26B-4EFC187B277D[ at ]microsoft.com...
[Quoted Text]
>I am trying to create a simple user defined report form for a range of
> records between a chosen start and end date but keep getting this compile
> and
> syntax error instead of the report, am I missing something?
>
> Private Sub Command4_Click()
>
> Dim ReportName
> ReportName = "Stores Start Order" _
> DoCmd.OpenReport _
> ReportName:=ReportName, _
> view:=acViewPreview, _
> WhereCondition:="[StartConstCur]between #"& _
> Me.StartDate& "# and #" & _
> Me.EndDAte & "#"
>
> End Sub
>


RE: Frustrating Form Coding Error
Scot Dever 12/2/2008 5:06:09 PM
Thank You Doug, Quick follow up. Can I insert this code into ay report,
changing the report name and where condition appropriately of coarse

"Scot Dever" wrote:

[Quoted Text]
> I am trying to create a simple user defined report form for a range of
> records between a chosen start and end date but keep getting this compile and
> syntax error instead of the report, am I missing something?
>
> Private Sub Command4_Click()
>
> Dim ReportName
> ReportName = "Stores Start Order" _
> DoCmd.OpenReport _
> ReportName:=ReportName, _
> view:=acViewPreview, _
> WhereCondition:="[StartConstCur]between #"& _
> Me.StartDate& "# and #" & _
> Me.EndDAte & "#"
>
> End Sub
>
Re: Frustrating Form Coding Error
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/2/2008 5:26:00 PM
That code should be on a form, not a report.

Yes, you can change the report name and condition and run it anywhere.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Scot Dever" <ScotDever[ at ]discussions.microsoft.com> wrote in message
news:DB589587-6A3A-44A1-AD7F-A40C7A5C43D7[ at ]microsoft.com...
[Quoted Text]
> Thank You Doug, Quick follow up. Can I insert this code into ay report,
> changing the report name and where condition appropriately of coarse
>
> "Scot Dever" wrote:
>
>> I am trying to create a simple user defined report form for a range of
>> records between a chosen start and end date but keep getting this compile
>> and
>> syntax error instead of the report, am I missing something?
>>
>> Private Sub Command4_Click()
>>
>> Dim ReportName
>> ReportName = "Stores Start Order" _
>> DoCmd.OpenReport _
>> ReportName:=ReportName, _
>> view:=acViewPreview, _
>> WhereCondition:="[StartConstCur]between #"& _
>> Me.StartDate& "# and #" & _
>> Me.EndDAte & "#"
>>
>> End Sub
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net