Solved

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

Posted on 2013-11-21
5
882 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now