Solved

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

Posted on 2013-11-21
5
954 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

739 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