Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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 …
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…

680 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