Solved

Set field value to True if record in Microsoft Access database has been created or modified

Posted on 2013-11-21
5
919 Views
Last Modified: 2013-11-27
I have a client with a Microsoft Access database. We have a "bit" field called Changed that can be set to True or False. The client is supposed to set that field to True whenever changes are made, or if its a new record. Then once a week, after we do a sync process with a web server, he resets everything back to False.

What I'm wondering, is if there is some way that Changed can be set to True automatically, without requiring him to remember to do so… whenever a new record is added or an old record is modified.

I don't use Access on a regular basis, so I really don't know what is possible. Would appreciate any advice.

Thank you!
0
Comment
Question by:bbdesign
  • 2
  • 2
5 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39666916
Add a line of code to the BeforeUpdate event, which runs when changes are made:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Me.Changed = True
End Sub

Open in new window


If you have existing code in the Before Update event, place that line of code towards the end, after any validation code.
0
 
LVL 12

Expert Comment

by:pdebaets
ID: 39666939
Along with the comment above, make sure that the only way for users to add or update records is through a form - and make sure the form contains the code described above. This may involve hiding your tables and/or preventing the database window/navigation pane from appearing.
0
 

Author Comment

by:bbdesign
ID: 39666967
Sorry if this is a beginner question, but where do I find "the BeforeUpdate event"? And this would cover both new records and modification of old records? I believe all updates are through a single form. Thanks!
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39667085
- Open the form in Design View
- Open the properties sheet
- Click the Events tab
- Click the ... next to Before Update
- Select Code Builder

Then place line 2 in my example above between the Sub and End Sub lines.
0
 

Author Comment

by:bbdesign
ID: 39681920
This is great advice, thanks for all your help.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question