Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating records only if changes have been made to the records.

Status
Not open for further replies.

Leaner79

Programmer
Jan 17, 2006
25
0
0
BW
Hi,
I have the following situation.
I have a switchboard form which has 1 buttons (Add And Edit)
I have a patient record form, which has 2 fields, (DateRecCaptured and DateRecUpdated)
Both buttons on the switchboard open the Patient Record form (one opens it in Add mode and the other in Edit mode)

This is what should happen.
If I click on the add button on the switchboard, the patient record form should open to allow me to add a record. The system date should then automatically be saved in the DateRecCaptured field.
If i click on the Edit button and edit a record, the system date should be saved in the DateRecUpdated field. If no updates are made, the field shouldn't be updated. If you scroll among records, the DateRecUpdated field shouldn't be updated. When editing, the DateRecCaptured field should remain unchanged.

Thanx
 
You can use the form's Dirty property to detect whether changes have been made to the currently displayed record, i.e.
Code:
If Me.Dirty Then
 'Do your update code
End If
 
How about adding two additional buttons to the for ADD and EDIT, keeping the records locked until one of the buttons is clicked. That way you can protect the exsisting records, or am I looking too deep into this?


Ian Mayor (UK)
Program Error
Programmers do it one finger at a time!
 
Forget the buttons, let Access handle this when the record is actually saved ...

In your patient form, use the before update event, which fires when the record is actually saved to stuff your dates into the form controls

[tt]if me.newrecord then
me!txtDateRecCaptured.Value = Now ' or Date
end if
me!txtDateRecUpdated.Value = Now ' or Date[/tt]

Use only Date if you're after only the date. Now gives a full timestamp (Date and Time).

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top