misuser2k7
MIS
I am working with a SQL Server database table which has a couple of Date (datetime, null) columns (‘FirstSurveyDate’ and ‘SecondSurveyDate’) in which some date records in ‘FirstSurveyDate’ column are NULL. This table is linked to Access.
I am using a simple query to show all the records from this table in a report. In the report, there is only one Survey date field (text box) which needs to display the date the (any, first or second or both) survey was taken. If the First date is available the second date doesn’t need to be displayed. But if the first date is not available (that is, the survey was taken on the second date), the second date needs to be displayed. Second surveys are mandatory and therefore these dates are never NULL.
In the report, I have placed two text boxes (‘FirstSurveyDate’ and ‘SecondSurveyDate’)where the second box is placed over the first.
What I want to do is …… if the first survey date is NULL then second survey date should be displayed. If the first survey date is not NULL then the first survey date should be displayed but not the second.
I tried the following in both the report’s ‘On Load’ and ‘Detail – Format’ event/procedures ……
If IsNull(Me.FirstSurveyDate) then
Me.SecondSurveyDate.Visible = True
Me.FirstSurveyDate.Visible = False
Else
Me.SecondSurveyDate.Visible = False
Me.FirstSurveyDate.Visible = True
End If
But this does not have the intended effect. Both the textboxes display their content i.e. if both dates are not NULL they both get displayed which is something that shouldn’t happen.
I tried setting the ‘Can Grow’ and ‘Can Shrink’ properties of the First and Second text boxes to ‘Yes’ but that only works in the first box is not NULL and the Second is NULL.
I was wondering if ‘NULL’ in SQL Server is displayed as some invisible yet Not NULL entry in Access query output.
Please suggest a solution to this issue. Is there an alternative to using ‘IsNull’ in the above ‘If-Then’ statement to address this situation with NULL in SQL Server date field and its Access equivalent?
Thank you all for your help.