Any way to stop the default date from showing?

B

brian

I have an Access project that is obviously tied to a SQL Server d/b.
On one of my forms I show a datetime field - for product introduction
date. When I create the record I initialize the field to the default
date of 01/01/1900. Is there anyway I can prevent this date from
showing up on my form? I only want to show dates that the users enter.

Thanks, Brian
 
R

Rob Parker

I assume that the date is a required field, so you can't leave it empty -
which would be the simplest solution ;-)

One simple way would be to use conditional formatting for the textbox; if
the date is 01/01/1900 set the text colour to the same as the background
colour of the control.

HTH,

Rob
 
M

Mr B

Just set the Visible property of that control to "NO". Ti will remain on the
form but will not be visible.
 
B

brian

No it's not a required field but I don't like dealing with NULLS,
unless that's not what you meant. Regarding making the text colour =
background colour then whenever they type a date into the field they
can't see it, how do you solve that? To bad you can't just load spaces
to the date field.

Brian
 
R

Rob Parker

Well, I think dealing with nulls is probably easier than the convolutions to
hide a specific data value ;-)

Apart from that ...

I was going too suggest using the GotFocus event of the textbox to reset the
text colour when the user moves to the field so that they can see the
existing entry, and their changing entry. However, when I test this, I find
that the conditional formatting is not over-ridden until the new entry is
completed, so you can't see what you are typing.

Then I tried use the Change event, which will not trigger until you actually
enter a character, but will trigger for each character entered. This does
override the conditional formatting immediately; unfortunately, it also
produces an Invalid Date error for each character entered. Maybe you could
trap this and ignore until a valid date exists in the field.

Other events (Dirty, Keypress, Enter) for the textbox give similar behaviour
to either the GotFocus or Change events.

Other than that, it seems my (off-the-top-of-my-head) suggestion is not all
that workable. Sorry 'bout that.

Would you like to re-consider working with nulls? It's not really difficult
at all. And you can always use the NZ function to convert any null fields
to a meaningless valid date, such as 01/01/1900 :)

HTH,

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top