Date Stamp in Table
am 26.11.2007 12:27:03 von Tang
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
Re: Date Stamp in Table
am 26.11.2007 12:40:51 von DM McGowan II
"Tang" wrote in message news:7bc9976326d73@uwe...
> 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
Re: Date Stamp in Table
am 26.11.2007 12:47:23 von Jebusville
"Tang" wrote in message news:7bc9976326d73@uwe...
> 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
Re: Date Stamp in Table
am 26.11.2007 12:48:09 von m-sjoblom
On 26 Nov, 12:27, "Tang" wrote:
> 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=B4")
Re: Date Stamp in Table
am 26.11.2007 18:46:31 von DM McGowan II
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.
wrote in message
news:f0f934b6-4fe7-4ecf-bc56-98cb25fb924d@r60g2000hsc.google groups.com...
On 26 Nov, 12:27, "Tang" wrote:
> 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´")