PDA

View Full Version : Ignore Null field problem



columbo1977
05-27-2010, 04:24 AM
Hi Guys

I have a Database that uses the GroupWise email system. The query form I am using has 2 possible arguments selected from Combo boxes. The user can choose a geographical area and then the code will email the query result to the people for that area.

I also want the users to have the ability to email the records for a particular month instead of just for the area.

I have got this working by making the system ask for a manual email address.

The problem that I am having is that when the area field is blank I am getting the error message 94 - Invalid Use of Null??

below is the code where I am trying to ignore the field if it is Null



If Forms!frmMonthlyReportAllCases!cboArea.Value = Null Then

Locality = ""

Else

Locality = Forms!frmMonthlyReportAllCases!cboArea.Value

End If

'Locality = Forms!frmMonthlyReportAllCases!cboArea.Value

Subj = "Please find attached for the month of " & MonthName(Month(Now()))
BodyText = "If you have any questions please contact me ."
'Open the form for exporting.
stDocName = "rptMonthlyReportAllCases"
DoCmd.OpenReport stDocName, acPreview


Any Ideas?

Graham

OBP
05-27-2010, 05:27 AM
Graham, you may be changing the Null on the form, but not in the table or query. Ideally you could have a "-" in all the Null Areas, you could make it the default value for the Area field on your data entry form.
You can also run an Update query to set all the Is Nulls to "-".

columbo1977
05-27-2010, 07:42 AM
Hi

Yes I think that was the problem, I ended up doign something similar in setting a default value so that it would work.

Thanks

Graham