date function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field with a function Date(), which updates everyday for the same
record

how can I have a Date() which will ofcourse does populate the current date
in the date field but in addition to this, it should not change or update ,
next day or onwards

plz help.

Manythanks
 
If I understand correctly, you have a text box whose Control Source is set
to:
=Date()
so that it always shows today's date.

If you wanted to record the date when a record was first entered:
1. Open your table in design view.
2. Add a new Date/Time field named (say) EnteredOn
3. In the lower pane of table design, set its Default Value property to:
=Date()

If you want to record the date when the record was last changed:
1. In table design, add another Date/Time field named (say) UpdatedOn.
2. Open the form where you alter the data in design view.
3. Set the BeforeUpdate event of the *form* to:
[Event Procedure]
4. Click the Build button beside the property.
Access opens the code window.
5. Set up the code like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[UpdatedOn] = Date()
End Sub

Note: If you want to record the time as well as the date, use =Now() instead
of =Date().
 
Thanks for your input, did work on the solution

Now I have 3 date field in one table
date field 1 is Date()
date field 2 has Me.[UpdatedOn] = Date()
date field 3 has Me.[UpdatedOn] = Date()

if system date changes the date field 2 and 3 changes, can I not have it
fixed , i.e.
date field 2 entered is 28/11/05
tomo. I changed date field 3 to 29/11/05, so I need date field 2 to be
28/11/05
and date field 3 to be 29/11/05. i.e. can be updated only once

p.s. I have each date field in 3 different tab page in one tab control

Hope its clear

Thanks



Allen Browne said:
If I understand correctly, you have a text box whose Control Source is set
to:
=Date()
so that it always shows today's date.

If you wanted to record the date when a record was first entered:
1. Open your table in design view.
2. Add a new Date/Time field named (say) EnteredOn
3. In the lower pane of table design, set its Default Value property to:
=Date()

If you want to record the date when the record was last changed:
1. In table design, add another Date/Time field named (say) UpdatedOn.
2. Open the form where you alter the data in design view.
3. Set the BeforeUpdate event of the *form* to:
[Event Procedure]
4. Click the Build button beside the property.
Access opens the code window.
5. Set up the code like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[UpdatedOn] = Date()
End Sub

Note: If you want to record the time as well as the date, use =Now() instead
of =Date().

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
I have a field with a function Date(), which updates everyday for the same
record

how can I have a Date() which will ofcourse does populate the current date
in the date field but in addition to this, it should not change or update
,
next day or onwards
 
These 3 suggestions have different purposes:

1. Always today:
If you always want today's date to show in a text box, you do not need a
field for it. Just bind the text box to:
=Date()
Now you don't have to update the field every day.

2. Creation date:
Use the Default Value of the field in the table. This does not change when
the record is later updated.

3. Modification date:
Use the BeforeUpdate event procedure of the form. This does change when the
record is later updated.

You can have mulitple text boxes on different pages of your tab control that
show the contents of the same field.


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
Thanks for your input, did work on the solution

Now I have 3 date field in one table
date field 1 is Date()
date field 2 has Me.[UpdatedOn] = Date()
date field 3 has Me.[UpdatedOn] = Date()

if system date changes the date field 2 and 3 changes, can I not have it
fixed , i.e.
date field 2 entered is 28/11/05
tomo. I changed date field 3 to 29/11/05, so I need date field 2 to be
28/11/05
and date field 3 to be 29/11/05. i.e. can be updated only once

p.s. I have each date field in 3 different tab page in one tab control

Hope its clear

Thanks



Allen Browne said:
If I understand correctly, you have a text box whose Control Source is
set
to:
=Date()
so that it always shows today's date.

If you wanted to record the date when a record was first entered:
1. Open your table in design view.
2. Add a new Date/Time field named (say) EnteredOn
3. In the lower pane of table design, set its Default Value property to:
=Date()

If you want to record the date when the record was last changed:
1. In table design, add another Date/Time field named (say) UpdatedOn.
2. Open the form where you alter the data in design view.
3. Set the BeforeUpdate event of the *form* to:
[Event Procedure]
4. Click the Build button beside the property.
Access opens the code window.
5. Set up the code like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[UpdatedOn] = Date()
End Sub

Note: If you want to record the time as well as the date, use =Now()
instead
of =Date().

Gerald said:
I have a field with a function Date(), which updates everyday for the
same
record

how can I have a Date() which will ofcourse does populate the current
date
in the date field but in addition to this, it should not change or
update
,
next day or onwards
 
thanks,

If I have 1 tab control and 3 tab pages, can I have 1 form in each tab strip

wondering if its possible

Allen Browne said:
These 3 suggestions have different purposes:

1. Always today:
If you always want today's date to show in a text box, you do not need a
field for it. Just bind the text box to:
=Date()
Now you don't have to update the field every day.

2. Creation date:
Use the Default Value of the field in the table. This does not change when
the record is later updated.

3. Modification date:
Use the BeforeUpdate event procedure of the form. This does change when the
record is later updated.

You can have mulitple text boxes on different pages of your tab control that
show the contents of the same field.


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
Thanks for your input, did work on the solution

Now I have 3 date field in one table
date field 1 is Date()
date field 2 has Me.[UpdatedOn] = Date()
date field 3 has Me.[UpdatedOn] = Date()

if system date changes the date field 2 and 3 changes, can I not have it
fixed , i.e.
date field 2 entered is 28/11/05
tomo. I changed date field 3 to 29/11/05, so I need date field 2 to be
28/11/05
and date field 3 to be 29/11/05. i.e. can be updated only once

p.s. I have each date field in 3 different tab page in one tab control

Hope its clear

Thanks



Allen Browne said:
If I understand correctly, you have a text box whose Control Source is
set
to:
=Date()
so that it always shows today's date.

If you wanted to record the date when a record was first entered:
1. Open your table in design view.
2. Add a new Date/Time field named (say) EnteredOn
3. In the lower pane of table design, set its Default Value property to:
=Date()

If you want to record the date when the record was last changed:
1. In table design, add another Date/Time field named (say) UpdatedOn.
2. Open the form where you alter the data in design view.
3. Set the BeforeUpdate event of the *form* to:
[Event Procedure]
4. Click the Build button beside the property.
Access opens the code window.
5. Set up the code like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[UpdatedOn] = Date()
End Sub

Note: If you want to record the time as well as the date, use =Now()
instead
of =Date().

I have a field with a function Date(), which updates everyday for the
same
record

how can I have a Date() which will ofcourse does populate the current
date
in the date field but in addition to this, it should not change or
update
,
next day or onwards
 
Back
Top