Form and default dates

R

Robbro

Related to my question below.... I'm setting up a form to filter results of a
query, I'm trying to set default dates (at the least so when you open the
form nothing will be filtered by default, at the best I'd like to be able to
open the form directly without it prompting me to enter values for the
filters and just show everything by default)
At any rate I have 2 issues now.
First no matter what I put in Default Value for my date entry boxes on my
filtering form, 12/30/1899 shows up in both.
Second as soon as I click in one of the boxes to enter a date it changes
from 12/30/1899 to a time like 12:07:10 AM or something.
Short Date is selected as the format for both boxes.
 
J

Jerry Whittle

Access stores the date 12/30/1899 as 0. Therefore something in that field is
already showing a 0. What is the default value in the table? That's probably
where you want to set it anyway.

Also remember that the default value is only for new records. If you open
the form to an existing record, Access will display what is there.

The other number for abut 7 minutes into the day is about 0.0049. Hard
telling where that comes from.
 
R

Robbro

Apparently even though I've set it to Short Date its interpreting 2/20/2010
as 2 divided by 20 divided by 2010. I guess I need to do somethign else to
make it recognize that as a date?
 
A

Arvin Meyer [MVP]

While you are using a web browser, at least 90% of those who are
knowledgeable enough to answer will be using newsreaders (like Agent,
Outlook Express, Windows Mail, or Thunderbird). We have no idea what your
question below is. For anyone using a web browser, below could be on a
completely different page and they couldn't find it without persistence and
luck,

That said, your answers are in line:


Robbro said:
Related to my question below.... I'm setting up a form to filter results
of a
query, I'm trying to set default dates (at the least so when you open the
form nothing will be filtered by default, at the best I'd like to be able
to
open the form directly without it prompting me to enter values for the
filters and just show everything by default)
At any rate I have 2 issues now.
First no matter what I put in Default Value for my date entry boxes on my
filtering form, 12/30/1899 shows up in both.
Second as soon as I click in one of the boxes to enter a date it changes
from 12/30/1899 to a time like 12:07:10 AM or something.
Short Date is selected as the format for both boxes.

Somewhere the default is set to 0 (zero) which is 12/30/1899. Check the
table, the form, and any code connected to the textbox or form. Similar to
the first problem is the second. I'd guess it's likely code in the GotFocus,
or Rnter property of the textboxes causing both problems.
 
J

John W. Vinson

Apparently even though I've set it to Short Date its interpreting 2/20/2010
as 2 divided by 20 divided by 2010. I guess I need to do somethign else to
make it recognize that as a date?

My guess is that you've put just

2/20/2010

in the DefaultValue property. That's being interpreted as 2, divided by 20,
divided by 2010 - .00004975... , which when translated to a date/time is about
12:00:04 on January 30, 1899.

The trick is that the default value must be a String - try

"2/20/2010"

or, better, use the builtin date functions to set it to a date tied to today's
date. For instance if you want it to default to tomorrow's date, you could set
the textbox's default value property to

=DateAdd("d", 1, Date())

or for the first of the current month to

=DateSerial(Year(Date()), Month(Date()), 1)
 
D

David W. Fenton

While you are using a web browser, at least 90% of those who are
knowledgeable enough to answer will be using newsreaders (like
Agent, Outlook Express, Windows Mail, or Thunderbird). We have no
idea what your question below is. For anyone using a web browser,
below could be on a completely different page and they couldn't
find it without persistence and luck,

There's no guarantee of proper ordering in a news reader, either.
Some newsreaders thread on the References: line, others on other
information in the headers. And a user can read in threaded view or
sort by subject and date, or all posts by date, etc.
 
D

David W. Fenton

For instance if you want it to default to tomorrow's date, you
could set the textbox's default value property to

=DateAdd("d", 1, Date())

Why bother with DateAdd() when Date() + 1 will give exactly the same
result? Sure, for anything other than days, you need DateAdd(), but
given that the integer part of a value of date type is the number of
days since 12/30/1899, you can add/subtract days without using
DateAdd().
 
A

Arvin Meyer [MVP]

David W. Fenton said:
There's no guarantee of proper ordering in a news reader, either.
Some newsreaders thread on the References: line, others on other
information in the headers. And a user can read in threaded view or
sort by subject and date, or all posts by date, etc.

Yes but most of that is under the user's control. Besides it doesn't change
the fact that "question below" is meaningless in most cases.
 
D

David W. Fenton

Yes but most of that is under the user's control. Besides it
doesn't change the fact that "question below" is meaningless in
most cases.

I think it's meaningless outside the sole context in which the user
is reading -- it won't mean anything to anybody else, ever, except
accidentally.

It's like with people asking about having their data tables in
Access sorted -- sort order is something you do in SQL, for a
particular situation, not something inherent to the data (at least
not in any obvious way, clustered indexes aside).
 

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