LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Programming for a Dynamic 'Where' clause

Hello

I have a form, which lets a user select a report and combo boxes to select
its criteria(s).

Example: "New Business Report" (State = 'NY', Region = North America)

Once a user selects the report and sets the criteria 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 (State = NY) 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 want to add a date range as a criteria option. I don't
know how to write the syntax though.

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

Any help would be much appreciated.

Thanks
AC

 
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
PERCENTILE with an IF Clause Zeelotes Excel Worksheet Functions 3 April 19th 23 02:11 PM
IF Clause dpal Excel Worksheet Functions 8 July 19th 07 07:32 PM
"Between" in an IF clause gavin Excel Discussion (Misc queries) 5 May 2nd 05 09:27 PM
Creating/programming an Excel dynamic graph SeqZ Excel Programming 2 May 29th 04 03:12 PM
if then clause in a cell mikewild2000 Excel Programming 3 January 29th 04 04:35 PM


All times are GMT +1. The time now is 04: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"