If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Null Values
Hello,
I am running the following code to produce a report with a where clause based upon a users selection in a set of combo boxes. How do I handle 'Null' values. What do I need to do if the user does not enter anything in these combo boxes. Right now their default is blank. Any help would be much appreciated. Thanks AC strWhere = "[Country] = '" & Me!cmb_Country & "' and [Region] = '" & Me!cmb_Region & "' and [ClientSector] = '" & Me!cmb_Sector & "'" Select Case Me!ReportToPrint Case 1 DoCmd.OpenReport "rpt_New_Bus_Wins_by_Sector", PrintMode, , strWhere Case 2 DoCmd.OpenReport "rpt_Profitability_Analysis", PrintMode, , strWhere Case 3 DoCmd.OpenReport "rpt_RePrice", PrintMode, , strWhere |
#2
|
|||
|
|||
Change your existing strWhere expression to:
If Not IsNull(Me!cmb_Country) Then strWhere = "[Country] = '" & Me!cmb_Country & "'" End If If Len(strWhere) 1 Then strWhere = strWhere & " And " If Not IsNull(Me!cmb_Country) Then strWhere = strWhere & "[Region] = '" & Me!cmb_Region & "'" End If If Len(strWhere) 1 Then strWhere = strWhere & " And " If Not IsNull(Me!cmb_Country) Then strWhere = strWhere & "[ClientSector] = '" & Me!cmb_Sector & "'" End If HTH, Nikos |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Null values in strings | Steve | General Discussion | 3 | September 25th, 2005 04:02 PM |
Null values in merged query fields | Joe Ventre | Running & Setting Up Queries | 2 | August 2nd, 2005 06:52 PM |
criteria and null values | Carlee | Running & Setting Up Queries | 1 | February 9th, 2005 04:02 AM |
Values not equal but not returning in Query | Lynn Arlington | Running & Setting Up Queries | 7 | October 1st, 2004 06:23 PM |
average, eliminating zero values | Chris | Worksheet Functions | 6 | May 14th, 2004 11:36 PM |