dbTalk Databases Forums  

Date Stamp in Table

comp.databases.ms-access comp.databases.ms-access


Discuss Date Stamp in Table in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tang
 
Posts: n/a

Default Date Stamp in Table - 11-26-2007 , 05:27 AM






Hi, could anybody help me with this please
I want to add a date stamp in a table, it should automaticlly updated when
another field in the same table is selected as "Yes". I am not very good at
VB code, so please if at all that can be avoided otherwise please be a bit
thourough on the codes including the declaration bit. Thanks


Reply With Quote
  #2  
Old   
Neil
 
Posts: n/a

Default Re: Date Stamp in Table - 11-26-2007 , 05:40 AM






"Tang" <u39375@uwe> wrote

Quote:
Hi, could anybody help me with this please
I want to add a date stamp in a table, it should automaticlly updated when
another field in the same table is selected as "Yes". I am not very good
at
VB code, so please if at all that can be avoided otherwise please be a bit
thourough on the codes including the declaration bit. Thanks

Can't be avoided. In the AfterUpdate event of the field on your form (which
I'll call YesNoField), enter the following:

If Me.YesNoField="Yes" Then Me.SomeDateField=Now()

Now, that assumes that your YesNoField is a text field that is set to the
value of "Yes." If, instead, it's a check box, which has checked/unchecked
values, use this instead:

If Me.YesNoField Then Me.SomeDateField=Now()

Finally, if you want to clear your date field if the value is unchecked,
then you'd use this:

If Me.YesNoField Then
Me.SomeDateField=Now()
Else
Me.SomeDateField=Null
End If

Note 1: This only works through the form. If you user updates YesNoField
directly through the table, the date field won't be updated.

Note 2: Now() will put the date and the time in your field. If, instead, you
only want the date, use VBA.Date instead of Now().

HTH,

Neil




Reply With Quote
  #3  
Old   
Keith Wilby
 
Posts: n/a

Default Re: Date Stamp in Table - 11-26-2007 , 05:47 AM



"Tang" <u39375@uwe> wrote

Quote:
Hi, could anybody help me with this please
I want to add a date stamp in a table, it should automaticlly updated when
another field in the same table is selected as "Yes". I am not very good
at
VB code, so please if at all that can be avoided otherwise please be a bit
thourough on the codes including the declaration bit. Thanks

If you want the time to be recorded whenever a change is made to any field,
something like this in your form's Before Update event should work:

Me.txtMyTextBox = Now()

where txtMyTextBox is the name of the text box bound to the date field.

If you want the time to be recorded when the value in another control on the
form is changed then put the same code in that control's After Update event.

Keith.
www.keithwilby.com



Reply With Quote
  #4  
Old   
m-sjoblom@telia.com
 
Posts: n/a

Default Re: Date Stamp in Table - 11-26-2007 , 05:48 AM



On 26 Nov, 12:27, "Tang" <u39375@uwe> wrote:
Quote:
Hi, could anybody help me with this please
I want to add a date stamp in a table, it should automaticlly updated when
another field in the same table is selected as "Yes". I am not very good at
VB code, so please if at all that can be avoided otherwise please be a bit
thourough on the codes including the declaration bit. Thanks
1:In the table design mode add a new field for example TimeStamp with
datatype date/time.
2: Find the default Value on the general tab at the bottom of the
field names and add following code to the default value "now()" .
This give You a time stamp with date ande time.

You can also format the data added by using format(now(),"YYYY/MM/DDŽ")


Reply With Quote
  #5  
Old   
Neil
 
Posts: n/a

Default Re: Date Stamp in Table - 11-26-2007 , 11:46 AM



The OP wanted to update the date field when another field was modified. What
you wrote will only give the date field a default value; it will not update
it when the other field is modified.


<m-sjoblom (AT) telia (DOT) com> wrote

On 26 Nov, 12:27, "Tang" <u39375@uwe> wrote:
Quote:
Hi, could anybody help me with this please
I want to add a date stamp in a table, it should automaticlly updated when
another field in the same table is selected as "Yes". I am not very good
at
VB code, so please if at all that can be avoided otherwise please be a bit
thourough on the codes including the declaration bit. Thanks
1:In the table design mode add a new field for example TimeStamp with
datatype date/time.
2: Find the default Value on the general tab at the bottom of the
field names and add following code to the default value "now()" .
This give You a time stamp with date ande time.

You can also format the data added by using format(now(),"YYYY/MM/DDŽ")





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.