Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1014
  • Last Modified:

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

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
bbdesign
Asked:
bbdesign
  • 2
  • 2
1 Solution
 
mbizupCommented:
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
 
pdebaetsCommented:
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
 
bbdesignAuthor Commented:
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
 
mbizupCommented:
- 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
 
bbdesignAuthor Commented:
This is great advice, thanks for all your help.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now