Today's Date



Hi all,
Ive read the threads about the command to "add Today's Date/ Prefill" the
current date on a form. Ive tried serveral things to make this populate
-i.e. default of control = Date() . Also, i tried it out of v.b.

private sub on_click() = Today
end sub

These all WORKED, but now i cant seem to type anything into my "ID" field.
I cant type any apha or numeric values. All it says in the bottom left is
"calculating" then just leaves the field null/blank. Does this command not
work with certain relationships?

Id appreciate any help.


Gina Whipp


One thing I noticed right off the bat is that if your field is named 'date'
then Access is confused because it uses the word 'date' to assing today's
date. My first suggestion would be don't use 'date'. I also notice that
you are using 'Today' to mean 'Date', have you told your routine what
'Today' means? If not, it might be trying to insert a word, 'Today' into a
Date/Time field.

As for the 'can't type anything into your 'ID' field' further explanation is
needed. Remember, we can't see your database so we have no idea what your
'ID' field is or why you want to type into it. Is that some sort of Primary
Key or is it a Foreign Key?

Al Campagna

Don't name a Date field "Date." It is a reserved word in Access, and
can/will cause problems.

Did you place the = Date() in the DefaultValue property field, or the
ControlSource of your Date field? From the fact that you can't enter any
data in your date field leads me to think you put it in the ControlSource.
Use the DefaultValue property.
This would be the preferred method.

Regarding your code...
private sub on_click() = Today
end sub

Several problems there.
1. First... change the name of your date field to something like
2. The actual event is Click, not On_Click
3. Your Sub routine does not indicate what control the Click is
associated with
4. The Today method only applies to a Calendar Control... use Date()
5. I've always used the DoubleClick event to set values for controls.
If you use the Click, the date will change any time you access/select the
field with a mouse click.

Private Sub MyDate_DblClick(Cancel as Integer)
Me.MyDate = Date()
End Sub
Al Campagna
Microsoft Access MVP

"Find a job that you love... and you'll never work a day in your life."


Thank you for these suggestions (especially on click, and double click). As
of right now, i have not edited anything in v.b. I have simply put under my
date textboxt, under data, default value =DATE() and i still have the same
problem. Like i said before, the date is populating but i cant enter an
amount under my "PERM_ID" field which a simple alpha number inventory number.

My relationships look like this:

"Computer_ID"(primary key) linked (innerjoin) to "Perm_ID"(foreign key). My
Perm_ID contain ALL inventory values. Computer ID table is one of many
tables PERM_ID stores.

Gina Whipp


Innerjoin suggest a 'connection' in the query grid window but not in the
Relationships window. To me that means there is no relationship between the
tables, is that true?

You say ComputerID is a PK linked to PermID which is a FK BUT PermID stores
all of the Inventory values, I'm confused, what is the table that houses
ComputerID do? If PermID is in effect the effect the Inventory then
shouldn't that be the table with the PK? Perhaps explaining what you trying
to do would help.


There is a relationship in the relationships window: Computer ID to Perm ID.
Simply put, when i load the form I type in the Perm ID and all the text
values for Computer ID display. Perm ID = multiple inventory numbers
inclusive of the Computer ID information. For instance, it also holds
Printer IDs, Phone IDs and other hardware IDs to keep track of our IT

(PK) (No PK Assigned)
My form currently works, just when i enter this Date value, it wont let me
populate PERM ID

Thank you.

Gina Whipp


Okay, this is what I understand...

1. Open form
2. Type in PermID (I am assuming a combo box) and all the pertinenet
information shows up.

Here's where I get lost...

3. What table is the date field in that you are trying to update? Is it in
the table that houses PermID? And what does the date represent?
4. And why would you need to repopulate the PermID if you just used it to
get the values filled in on your form?
5. And what purpose does ComputerID have if it's already in the table that
houses PermID to your form?

Perhaps you should post the SQL you are using. This might help in
determining the problem.


The date value is in the ComputerID Table. ComputerID has many fields i.e.
operating system, mac address, date we reformatted it, warranty etc. The
PermID table only has 1 field (PermID)...the PermID for all the tables (i.e.
computerID number, printerID number, phoneID number). I have all these
tables linked to PermID this way if i enter the PermID on the form, other
fields from other tables can populate. I'm sorry, but I dont know how i can
be anymore clear. Its OK if you still don't get it, ill figure out another
way. Thank you for your time.

ComputerID---------------------PERM ID-123,456,7,8,9,10,11,12

Gina Whipp


I think I get it now and that's why I asked you to post the SQL to the query
you are using with the form. I beleive the join is incorrect. Example, if
I am pulling all the records from the PermID then when I try to enter a date
OR anything else on the ComputerID side there is nothing to match to, hence
I get a calculating message but nothing happens and my date is not stored
(and if error messages is turned off I may never know what is happeneing).
On the other hand if I pull only the records that are in the CompuerID table
then all should be well in the world.

I could be wrong but until you post the SQL I won't know.

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

Similar Threads