I can see the before update event when I click on properties. I'll explain
to you exactly how I get there:
* Open DB
* Go to Forms section of the objects
* Double click on the "Students" form (which is the form I want to add the
date to)
* Click on properties icon, now what I notice when I click on that icon is
it automatically goes to the first field "UniqueID" so it's showing me the
properties for that field. If instead of clicking on the properties icon in
the design view I can change the field to detail, I see the before update
even and go to the code builder and put in =[DateModified]=[«Expr»]=[Date]
but it doesn't work.
I'm just not sure what I'm doing wrong, I can see the field you are talking
about in the properties but it's not saving it there or it's only saving it
to a specific field.
Monique
Duane Hookom said:
When I view the Form properties (the word "Form" is in the title bar of the
property dialog) there are over 50 event properties (Access 2003). The fourth
event property in the dialog is "Before Update". This event property has been
there as long as I can remember.
--
Duane Hookom
Microsoft Access MVP
:
OK, I went straight to the main form in design view, clicked on the
properties icon and went to event tab, before update was not on the list, it
only shows if I actually click on the field properties of my DateModified
field, then when I click on the code builder it takes me to visual basic and
that's where I added the DateModified = Date as you suggested.
If I go back to the form view and change something it doesn't update that
field with the current date, if I click in that field and type anything it
comes back saying wrong data and autofills it with the current date but that
is only from me actually trying to enter data into that field.
Monique
:
Open your form in design view and display the properties dialog. Find your
form properties and then click the Event tab. Find the Before Update event
property and click the builder button on the right. Choose to enter some code
and then enter the code that I suggested. You will need to make sure the code
matches your control names.
--
Duane Hookom
Microsoft Access MVP
:
Can you please explain how to do that, I just can't work it out.
:
Again, the code should have been "added to the Before Update event of your
form". There shouldn't be any code in the update of the DateModified.
--
Duane Hookom
Microsoft Access MVP
:
Duane
OK, what I've done now is this, go into the form design, right click on the
date field then the event tab, now I've clicked on the little tab that took
me to visual basic, I put the code down like this:
Private Sub DateModified_BeforeUpdate(Cancel As Integer)
DateModified = Date
End Sub
So my field is just called DataModified but it is not doing anything.
Monique
:
The code should have been "added to the Before Update event of your form". I
don't know where you entered your code.
Did you change the code to match your text box names or change the text box
names to match the code?
--
Duane Hookom
Microsoft Access MVP
:
Well I've added as I said the DateModified and TimeModified field to my main
students table, put those 2 fields on my form, then I go into the design
section of the form, right click on the date modified box, click on the event
tab and then I put in the code you just wrote Me.txtDateModified = Date. I
then closed the form and saved it, went back in and modified a students
details in the form and it didn't put the date in there? Any clues.
Monique
:
This question would be more appropriate in the Forms Coding NG however, you
could add code to the Before Update event of your form to set
Me.txtDateModified = Date
Me.txtTimeModidfied = TimeValue(Now())
--
Duane Hookom
Microsoft Access MVP
:
I have a form where staff can go and add student information, I would like to
be able to capture when and if the form has been modified. We are running
reports on students with certain behaviours right now but we don't know how
up-to-date the data is if we don't capture if it's been changed recently.
I added TimeModified and DateModified to my main table and put the fields on
my form that I need it to capture but I'm not sure how to actually get it to
fill those fields once data has been modified, any help would be appreciated.
Monique