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!

Forcing an update when subform modified

Status
Not open for further replies.

BSman

Programmer
Apr 16, 2002
718
0
0
US
I have a form with two subforms. The main table includes a last updated column. Whenever any of the data is updated (including the subform data) I'd like to post the lasted date/time into the LastUpdated column. I can do that with the main form data using before update and before insert properties of the form; however, if I try to write to LastUpdated on the main form whenever I've changed data in a subform I get a message about a write conflict. If I click write changes it writes the new date/time, but I don't want the message to show at all. I tried setting a public variable to indicate a change was made, but I can't figure out what property would trigger before moving to the next record. Any ideas?

Bob
 
try in after update of subform
Code:
me.parent.lastupdatedcontrolname=now()
 
That's exactly what I was doing....and got the write conflict message:

"The record has been changed by another user since you started editing it. If you save the record you will overwrite the changes the other user made."

You can then click Save changes, Copy to clipboard, or Drop changes.

No one else is using this record and I still get this message, which I'm trying to avoid.

Bob
 
Although it doesn't quite work the way I'd like, I came up with a workaround.

In the subforms, for the before update and before insert properties I run a SQL statement that updates the parent form's table. The only problem is that the change is not reflected until you close the parent form and re-open it (from the menu form in the application).

Bob
 
Try updating the table directly

Code:
Dim cmd As New ADODB.Command
Dim a As Integer
InitializeAdo
cmd.CommandText = AdoString
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = 1
cmd.CommandTimeout = 0
cmd.Execute "update maintable set lastupdatefield=getdate()
where fk=" & me.fk
 
Did that already too. Access objected to that language in the subform.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top