Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hide date textboxes on report

Hide date textboxes on report

Hide date textboxes on report


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
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.

RE: Hide date textboxes on report

I think you can simply use a single text box with a control source of:

CODE --> ControlSource

=Nz([FirstSurveyDate], [SecondSurveyDate]) 

Hook'D on Access
MS Access MVP 2001-2016

RE: Hide date textboxes on report


Thank you Duane.

I used a single textbox (SurveyDate) as you suggested.

I entered your code in the control source property of the textbox but I get an #size! error. I don't what it means.

I then entered it in the Detail - Format as
Me.SurveyDate =Nz([FirstSurveyDate], [SecondSurveyDate])

But the issue persists.

RE: Hide date textboxes on report

Make sure the name of the text box is not the name of a field and You don't have a user defined function named "nz"

Hook'D on Access
MS Access MVP 2001-2016

RE: Hide date textboxes on report


Thank you Duane. It worked!

I was using the ‘FirstSurveyDate’ textbox which as you pointed out was the reason for the error.

I created a new textbox ‘SurveyDate’ and used =Nz([FirstSurveyDate], [SecondSurveyDate]) as its control source.

I got a #Type! Error for records with SecondSurveyDate.

I changed the code to …… =Nz([FirstSurveyDate],(Format$([ SecondSurveyDate],"mm/dd/yyyy"))).

This cleared the error and it’s works great.

Thank you.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close