Help!

Use combo to print report between two sets of dates

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Reports RSS
Next:  larne numbers of attachcment access 2007  
Author Message
MoonBlosm
External


Since: May 27, 2010
Posts: 1



PostPosted: Thu May 27, 2010 2:18 pm    Post subject: Use combo to print report between two sets of dates
Archived from groups: microsoft>public>access>reports (more info?)


I am trying to print a report that shows timesheet entries for two sets of
dates. The report also prints out based on the data entry person selected.
The user selects their name and then uses another combo box to select pre
entered dates.

My code is as follows:

Private Sub cboDates_Click()

Dim stDocName As String
Dim FromDate As Date 'Name of criteria start timesheets date field.
Dim ToDate As Date 'Name of criteria end timesheets date field.
Dim FromOTDate As Date 'Name of criteria start OT date field.
Dim ToOTDate As Date 'Name of criteria end timesheets date field.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
Dim strWhere As String


'DataEntry Combo
If Not IsNull(Me.cboDataEntry) Then
strWhere = strWhere & "([DataEntry] = """ & Me.cboDataEntry.Column(0) &
""") AND "
End If

'Date Combo
FromDate = Me.cboDates.Column(0)
ToDate = Me.cboDates.Column(1)
FromOTDate = Me.cboDates.Column(2)
ToOTDate = Me.cboDates.Column(3)

If Not IsNull(me.cboDates)Then
strWhere = strWhere & "([Date] Is Between " & Format(FromDate,
conDateFormat) _
& " And " & Format(ToDate, conDateFormat) & ") AND "
strWhere = strWhere & "([Date] Is Between " & Format(FromOTDate,
conDateFormat) _
& " And " & Format(ToOTDate, conDateFormat) & ")"
End If

stDocName = "RptTimeSheet"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End Sub

I keep getting the '3075' error, Syntax error (missing operator) in query
expression

'[DataEntry] = "Heather") AND ([Date] is Between #03/02/2010# And
#03/09/2010#) AND ([Date]) is Between #02/18/2010# And #02/24/2010))'

I am sure I am missing something quite simple, but once you have looked at
it for a few hours everything begins to blur Smile

Thanks for any help provided! I can't put a price on how valuable this site
is to me! Thank you to all the people providing questions and support.

~Nicole
Back to top
Wolfgang Kais
External


Since: May 20, 2010
Posts: 4



PostPosted: Fri May 28, 2010 5:10 am    Post subject: Re: Use combo to print report between two sets of dates [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hello Nicole

Nicole "MoonBlosm" wrote:
[snip]
> If Not IsNull(me.cboDates)Then
> strWhere = strWhere & "([Date] Is Between " & Format(FromDate,
> conDateFormat) _
> & " And " & Format(ToDate, conDateFormat) & ") AND "
> strWhere = strWhere & "([Date] Is Between " & Format(FromOTDate,
> conDateFormat) _
> & " And " & Format(ToOTDate, conDateFormat) & ")"
> End If
[snip]
> I keep getting the '3075' error, Syntax error (missing operator)
> in query expression
>
> '[DataEntry] = "Heather") AND ([Date] is Between #03/02/2010# And
> #03/09/2010#) AND ([Date]) is Between #02/18/2010# And #02/24/2010))'
>
> I am sure I am missing something quite simple, but once you have
> looked at it for a few hours everything begins to blur Smile

The "between" operator has no "is", so try this:
If Not IsNull(me.cboDates) Then
strWhere = strWhere & "([Date] Between " & Format(FromDate, conDateFormat)
_
& " And " & Format(ToDate, conDateFormat) & ") AND "
strWhere = strWhere & "([Date] Between " & Format(FromOTDate,
conDateFormat) _
& " And " & Format(ToOTDate, conDateFormat) & ")"
End If

--
Regards,
Wolfgang
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Reports All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum