A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Null Values



 
 
Thread Tools Display Modes
  #1  
Old August 11th, 2005, 03:43 PM
ACase
external usenet poster
 
Posts: n/a
Default 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  
Old August 12th, 2005, 09:15 AM
Nikos Yannacopoulos
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 06:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.