You need a Date/Time field - InvoiceDate let's say - in the Table. A
textbox on a Form is NOT the same thing! Set the table field's Default
property to Date(); it will populate with the date at the moment the
record is created, and retain that value.
John W. Vinson[MVP]
John Vinson wrote:
> On Sun, 17 Jul 2005 21:18:11 -0700, "tx sales" <tx
> sa...@discussions.microsoft.com> wrote:
>
> >I have created a database to use for my invoicing. The date field always
> >changes on past records to the current date.
>
> You need a Date/Time field - InvoiceDate let's say - in the Table. A
> textbox on a Form is NOT the same thing! Set the table field's Default
> property to Date(); it will populate with the date at the moment the
> record is created, and retain that value.
Is not guaranteed to retain the value:
CREATE TABLE Test1
(key_col INTEGER NOT NULL,
created_date DATETIME DEFAULT DATE() NOT NULL);
INSERT INTO Table1 (key_col) VALUES (1);
UPDATE Test1
SET created_date = #1987-01-01#
WHERE key_col = 1;
Two procedures are required. One to create the row using the current
(created) date. Another to update the data but not the created date.
Grant privileges to the procs. Revoke permissions from the base tables.
Name:
Control Source:
Default Value:
Also the properties from the field in the table:
Name:
Default Value:
--
Duane Hookom
MS Access MVP
"tx sales" <txs...@discussions.microsoft.com> wrote in message
news:79408475-D343-4041...@microsoft.com...
In the table section
Name: Invocie Date
Default Value: Date()
Thanks for any help you can give
BruceM wrote:
> > > Set the table field's Default
> > > property to Date(); it will populate with the date at the moment the
> > > record is created, and retain that value.
> >
> > Is not guaranteed to retain the value:
> > Two procedures are required. One to create the row using the current
> > (created) date. Another to update the data but not the created date.
> > Grant privileges to the procs. Revoke permissions from the base tables.
>
> You have not demonstrated the need for more than what John has suggested.
I read "How can I set it to hold the date". A DEFAULT alone will not
achieve this.
--
Duane Hookom
MS Access MVP
--
"tx sales" <txs...@discussions.microsoft.com> wrote in message
news:10AAC930-2DC6-496B...@microsoft.com...
>I read "How can I set it to hold the date". A DEFAULT alone will not
>achieve this.
A Default on the table field, as I suggested, will in fact work
perfectly well.
When a new record is created, it will store the system clock date into
that table field, at the moment the record is first "dirtied".
That value will not change thereafter.
You're mistaken, I fear!
John W. Vinson[MVP]
John Vinson wrote:
> A Default on the table field, as I suggested, will in fact work
> perfectly well.
>
> When a new record is created, it will store the system clock date into
> that table field, at the moment the record is first "dirtied".
>
> That value will not change thereafter.
>
> You're mistaken, I fear!
An I think *you* are mistaken!
The DEFAULT is only applied when the row is first created (INSERT INTO)
and then only when no value was supplied. It don't stop users from
changing it (UPDATE). Try this
CREATE TABLE Test1
(key_col INTEGER NOT NULL PRIMARY KEY,
data_col INTEGER NOT NULL,
created_date DATETIME DEFAULT DATE() NOT NULL);
INSERT INTO Test1 (key_col, data_col, created_date)
VALUES (1, 1, #2020-12-31#);
-- created row with noncurrent date
UPDATE Test1
SET created_date = #1987-01-01#
WHERE key_col = 1;
-- changes also to noncurrent date
You say "That value will not change thereafter" but I just changed it!
Post back if you saw the current date, you may be running it
incorrectly.
The proper solution.
Logon to database as Admin, then
CREATE USER JohnV;
REVOKE ALL PRIVILEGES
ON TABLE Test1
FROM JohnV;
GRANT SELECT
ON TABLE Test1
TO JohnV;
CREATE PROCEDURE AddTest1
(:key_col INTEGER, :data_col INTEGER)
AS
INSERT INTO Test1 (key_col, data_col)
VALUES (:key_col, :data_col)
WITH OWNERACCESS OPTION;
GRANT UPDATE
ON OBJECT AddTest1
TO JohnV;
CREATE PROCEDURE UpdateTest1
(:key_col INTEGER, :data_col INTEGER)
AS
UPDATE Test1
SET data_col = :data_col
WHERE key_col = :key_col
WITH OWNERACCESS OPTION;
GRANT UPDATE
ON OBJECT UpdateTest1
TO JohnV;
Logon to database as JohnV, then
UPDATE Test1
SET created_date = #2002-02-02#
WHERE key_col = 1;
-- fails, cannot change created_date
INSERT INTO Test1 (key_col, data_col, created_date)
VALUES (2, 2, #2011-11-11#);
-- fails, cannot create row using created_date
EXECUTE AddTest1 2, 2;
-- success, created date is current
EXECUTE UpdateTest1 2, 999;
-- success, created date still is current
tx sales wrote:
> ok now you have really lost me, I am new to the access stuff, and really have
> no idea about anything you previously wrote.
Bottom line: if you don't want anyone/anything (Form etc.) to change
you data, don't let them and that means using security.
In the table section
Name: Invocie Date
Default Value: Date()
================================
Clearly the control source should be the name of the field whether it is
"Invocie Date" or "Invoice Date". The name of the control should be changed
to txtInvoiceDate. If this doesn't allow changing the value then the
recordset might not be updateable or a property value isn't allowing
updates.
--
Duane Hookom
MS Access MVP
<pere...@jetemail.net> wrote in message
news:1121766691.3...@z14g2000cwz.googlegroups.com...
Duane Hookom wrote:
> In the other branch of this thread
yes, I'm just looking at the .tablesdbdesign
>An I think *you* are mistaken!
>
>The DEFAULT is only applied when the row is first created (INSERT INTO)
>and then only when no value was supplied. It don't stop users from
>changing it (UPDATE). Try this
Sorry... we were talking past one another.
The OP was indicating that *ACCESS ITSELF* was changing the date; the
reason is apparently that he had the Control Source of a textbox set
to Date(), and was not displaying the table field at all.
I misunderstood your issue; you're quite correct, of course, that the
stored date field can be manually edited. However, unless someone
takes deliberate action to change it, Access won't change it on its
own.
John W. Vinson[MVP]
>Thanks John, I followed your instructions exactly and it keeps changing the
>date to the current date, it is not holding the date I created the record.
>All records have today's date.
>
You posted elsethread that the textbox has properties
in the form section the requested info as follows:
Name: Invoice Date
Control Source:-Date()
Default Value:Date()
The control source IS WRONG.
The Control Source property determines what will be displayed.
You have it set to Date(), so it will display today's date, regardless
of any field that is stored in your table.
Change the Control Source property to
[Invoice Date]
and you should be back in business.
John W. Vinson[MVP]
John Vinson wrote:
> I misunderstood your issue; you're quite correct, of course, that the
> stored date field can be manually edited. However, unless someone
> takes deliberate action to change it, Access won't change it on its
Think about it the other way around: if there is no mechanism to change
the date (apart from the Admin table owner) then it cannot be changed
by Access, an Access user, an Excel user, an ADO user, etc. This is,
after all, the database/tables group and not the frontend/forms group :)