Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Report Criteria

Hello

I am running reports, and enabling the user to set the criteria via a form.

The criteria works well, except when I tried adding a date range (See
Below). Not quite sure what the syntax is.

Any help would be much appreciated.

Thanks
AC
' THIS DOES NOT WORK '
If Not IsNull(Me.StartDt) And Not IsNull(Me.EndDt) Then
strWhere = strWhere & "([ProposalDate] Between """ & Me.StartDt And
Me.EndDt & """) AND "
End If

' THIS WORKS '
If Not IsNull(Me.cmb_RequestType) Then
strWhere = strWhere & "([RequestType] = """ & Me.cmb_RequestType & """)
AND "
End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Report Criteria

Database is what? If you debug.print the SQL what does it look like, and
can you run it in another query tool?
What error do you get?

Details elicit suggestions...

Tim

--
Tim Williams
Palo Alto, CA


"ACase" wrote in message
...
Hello

I am running reports, and enabling the user to set the criteria via a

form.

The criteria works well, except when I tried adding a date range (See
Below). Not quite sure what the syntax is.

Any help would be much appreciated.

Thanks
AC
' THIS DOES NOT WORK '
If Not IsNull(Me.StartDt) And Not IsNull(Me.EndDt) Then
strWhere = strWhere & "([ProposalDate] Between """ & Me.StartDt And
Me.EndDt & """) AND "
End If

' THIS WORKS '
If Not IsNull(Me.cmb_RequestType) Then
strWhere = strWhere & "([RequestType] = """ & Me.cmb_RequestType &

""")
AND "
End If



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Report Criteria

ACase,

Although i don't understand the specifics of your problem, I may be able to
shed some light on the formating with some examples:

strWhere = "1" 'defines old/existing string
strJunk = "3" 'defines another string variable

strWhere = strWhere & "2" & strJunk & str(2+2) & "5"
'combines the old string and the number 2 and another string
'and the result of str(2+2) and the number 5

MsgBox strWhere 'shows the output of 12345

Christmas May


"ACase" wrote:

Hello

I am running reports, and enabling the user to set the criteria via a form.

The criteria works well, except when I tried adding a date range (See
Below). Not quite sure what the syntax is.

Any help would be much appreciated.

Thanks
AC
' THIS DOES NOT WORK '
If Not IsNull(Me.StartDt) And Not IsNull(Me.EndDt) Then
strWhere = strWhere & "([ProposalDate] Between """ & Me.StartDt And
Me.EndDt & """) AND "
End If

' THIS WORKS '
If Not IsNull(Me.cmb_RequestType) Then
strWhere = strWhere & "([RequestType] = """ & Me.cmb_RequestType & """)
AND "
End If

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Report Criteria

Sorry for the confusing post.

I have a report form, which lets a user select a report and criteria for
that report (Country, Region, Department......)

Once a user has runs the report the 'Where' clause is created dynamically in
the code.

Example - In the code I have a series of statements which will check each
and every combo box. If the combo box is null it gets ignored, if it is
populated (COuntry = USA) then the criteria is added to the 'Where' clause.

If Not IsNull(Me.cmb_Country) Then
strWhere = strWhere & "([Country] = """ & Me.cmb_Country
End If

I now wanted to add the ability to select a date range as a filter. I don't
know how to write the syntax.

My 2 combo boxes on the user form are cmb_StartDate & cmb_EndDate.

What is wrong with this syntax?
If Not IsNull(Me.cmb_StartDate) and IsNull (Me.cmb_EndDate) Then
strWhere = strWhere & "([Date] = between """ & Me.cmb_StartDate and
Me.cmb_EndDate.
End If

Thanks
AC
"Christmas May" wrote:

ACase,

Although i don't understand the specifics of your problem, I may be able to
shed some light on the formating with some examples:

strWhere = "1" 'defines old/existing string
strJunk = "3" 'defines another string variable

strWhere = strWhere & "2" & strJunk & str(2+2) & "5"
'combines the old string and the number 2 and another string
'and the result of str(2+2) and the number 5

MsgBox strWhere 'shows the output of 12345

Christmas May


"ACase" wrote:

Hello

I am running reports, and enabling the user to set the criteria via a form.

The criteria works well, except when I tried adding a date range (See
Below). Not quite sure what the syntax is.

Any help would be much appreciated.

Thanks
AC
' THIS DOES NOT WORK '
If Not IsNull(Me.StartDt) And Not IsNull(Me.EndDt) Then
strWhere = strWhere & "([ProposalDate] Between """ & Me.StartDt And
Me.EndDt & """) AND "
End If

' THIS WORKS '
If Not IsNull(Me.cmb_RequestType) Then
strWhere = strWhere & "([RequestType] = """ & Me.cmb_RequestType & """)
AND "
End If

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Report using dates as a criteria UKMAN Excel Worksheet Functions 1 March 4th 10 05:10 PM
Need to report a count that meets multiple criteria. tkm Excel Worksheet Functions 2 July 29th 08 02:33 PM
Monthly Total report based on 2 or 3 criteria. VBA or Formula DbMstr Excel Discussion (Misc queries) 15 July 1st 07 10:37 PM
Print report based on criteria Rich Mogy Excel Discussion (Misc queries) 2 April 2nd 07 03:59 PM
report by DV & date criteria [email protected] Excel Worksheet Functions 2 March 26th 07 10:29 AM


All times are GMT +1. The time now is 01:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"