473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Auto Update a Date

19
I am trying to create a field in my Access 2007 form where, when you modify anything in the form it updates the date.

In other words, I have a "Date Update" field that I need to automatically update, only when something is modified on the form.

I'm a novice, so please explain in step by step terms!

Thank you!!!
Apr 2 '08 #1
11 5688
nico5038
3,080 Expert 2GB
Best to add some code to the form.
1) Open the form in design mode and directly press the [Properties] button.
2) Goto the Events tab and double-click the "BeforeUpdate" text so the field is filled with the text "Eventprocedure".
3) Press the [..] button behind the text and some pre created VBA code for the event will open.
4) Type within the sub:
Expand|Select|Wrap|Line Numbers
  1. Me.[Date Updated] = Now()
  2.  
5) close the code and save the form.

Access will now place the date and time in the field before the record is updated in the database.

BTW it's best not to use spaces in fieldnames...

Nic;o)
Apr 2 '08 #2
PaulaCM
19
Best to add some code to the form.
1) Open the form in design mode and directly press the [Properties] button.
2) Goto the Events tab and double-click the "BeforeUpdate" text so the field is filled with the text "Eventprocedure".
3) Press the [..] button behind the text and some pre created VBA code for the event will open.
4) Type within the sub:
Expand|Select|Wrap|Line Numbers
  1. Me.[Date Updated] = Now()
  2.  
5) close the code and save the form.

Access will now place the date and time in the field before the record is updated in the database.

BTW it's best not to use spaces in fieldnames...

Nic;o)

Nic -

Hmmm... this doesn't seem to be working for me. Firstly, I'd like it to update the date only after I've updated something. Secondly, it just didn't work :(

thanks for taking the time to help (again)!

best,
Apr 3 '08 #3
nico5038
3,080 Expert 2GB
Strange, the BeforeUpdate is only triggered when a change has been made to the form, thus it's just the event you need.

Did you make sure that the fieldname (see under the other tab of the properties) of the date field is correct ?

Nic;o)
Apr 3 '08 #4
PaulaCM
19
Thanks Nic!

It's working now. But, it only updates if I change something in one of my text fields, not if I click a yes/no tab.

Not a big deal, but it'd be good to have it update upon either.

Does that make sense?
Apr 4 '08 #5
nico5038
3,080 Expert 2GB
Thanks Nic!

It's working now. But, it only updates if I change something in one of my text fields, not if I click a yes/no tab.

Not a big deal, but it'd be good to have it update upon either.

Does that make sense?
I guess that the YesNo field isn't "bound" to a tablefield in the recordsource of the form. Open the properties of the field and check under the Data tab or a fieldname is filled for the controlsource
Access will by default automatically trigger the BeforeUpdate when one of the "bound" fields is changed....

Nic;o)
Apr 4 '08 #6
PaulaCM
19
Nico -

I'm sorry, but for some reason, this isn't working again. I do have some that updated, but now they aren't doing it.

Also, if i'm on one of the yes/no fields, I don't have any options under the data tab.

Sorry to be such a pain!
Apr 8 '08 #7
missinglinq
3,532 Expert 2GB
By being in the Form_BeforeUpdate event (which is where it should be) it isn't going to be reflected until the record is saved, either by explicitly saving it or moving off of the record then back to the record.

The reason you see nothing under the Data Tab for the checkbox, I suspect, is that you've actually selected the box's label, not the checkbox itself, which is a very common error.

Also, to get only the date, use

Me.[Date Updated] = Date()


Welcome to bytes!

Linq ;0)>
Apr 8 '08 #8
PaulaCM
19
I tried that!

I've tried saving the form, saving the record, moving off the record, everything that I can think of and now the date isn't updating!

I even found the datasource on the checkbox for my yes/no fields (thanks for the tip) and the source is the correct box.

so, I really don't know what I'm doing wrong...

here's what my code looks like:


Private Sub Date_Updated_BeforeUpdate(Cancel As Integer)
Me.[Date Updated] = Date
End Sub


The only thing I did was insert that line of code you gave me, so maybe it's part of the auto generated code that is somehow wrong?

thanks for the help!
Apr 8 '08 #9
nico5038
3,080 Expert 2GB
I tried that!

I've tried saving the form, saving the record, moving off the record, everything that I can think of and now the date isn't updating!

I even found the datasource on the checkbox for my yes/no fields (thanks for the tip) and the source is the correct box.

so, I really don't know what I'm doing wrong...

here's what my code looks like:


Private Sub Date_Updated_BeforeUpdate(Cancel As Integer)
Me.[Date Updated] = Date
End Sub


The only thing I did was insert that line of code you gave me, so maybe it's part of the auto generated code that is somehow wrong?

thanks for the help!
As indicated by Linq, you need to use the Form's BeforeUpdate event.
Your code is in the Date_Updated BeforeUpdate event.
Remove that code and click in the small grey square top left (between the horizontal end vertical ruler). When it has a small black square inside, the form is selected and the Properties window will allow you to chose the right BeforeUpdate event.
The form is by default selected when you open the form for Design mode, you can check the "black square" to see that.

Nic;o)
Apr 8 '08 #10
PaulaCM
19
I know that I'm being obtuse, but .... still not working....

Here's the code that I've used:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[Date Updated] = Date
End Sub


No updating of the date even when I save, exit, or move to another entry.

Thanks for your patience and your help (clearly, I'm a moron)
Apr 8 '08 #11
nico5038
3,080 Expert 2GB
Hmm, did you perhaps also use a formcontrol with the name [Date] ?
To be sure (and more precise), try to use Now() instead of Date in your assign statement.

When still not working, make a temp .mdb and add that as an attachment so we can have a look.

Nic;o)
Apr 8 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rene Aguirre | last post by:
Hello everybody, Recently I made a 'improvement' from an 'old' system we used for i2c bus testing as I had no access to the source code, I started from scratch on Python/wxPython. The idea...
1
by: efinney | last post by:
Hi, I'm a newbie to sql server and this may be a really dumb question for some you. I'm trying to find some examples of sql server triggers that will set columns (e.g. the created and modified...
2
by: MVA | last post by:
Hi all I have a database where in a table (tbl_Members), there are 2 date fields (DateOfBirth and DateJoined), and also 2 fields which upon entering the data in the form, it automatically works...
2
by: Kenny G | last post by:
Currently I have four datetime fields: DteTimeNotified DteTimeStarted DteTimeCompleted DteTimeReported Each of these fields contain the input mask 99/99/00" "00:00;0 This gives me a short...
17
by: Dino M. Buljubasic | last post by:
I am building an applicatin that will be able to automatically update itself from an FTP server. I'd like to be able to determine which version of application is newer, the one currently running...
5
by: mbyrd1332 | last post by:
Just wondering if any of you knew of a way to trap the <!-- #BeginDate format:Am1 -->April 4, 2006<!-- #EndDate --> (Dreamweaver's Auto-Update-on-Save Date Code) into a PHP variable and still have...
1
by: kunal0101 | last post by:
Hi, I am a new user to access and am building a database to capture the rotation dates for employees. There is a table called "Rotation schedule" which contains "name", "Duration (in weeks) and...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
0
by: Mogrin | last post by:
So I have this windows .net form app, and I have the following goals: -Needs to be 1 single file, the executable, in any directory the user decides to download it to. No installation folder, no...
8
by: pld60 | last post by:
Making progress with my data base but have run into a snag. Working with an unbound form that place data into more than one table using a "save" button with this code. Private Sub...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.