By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,622 Members | 1,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,622 IT Pros & Developers. It's quick & easy.

How to catch events between subforms

P: 52
I want to catch events between subforms whenever I changed data on the first form and click on the second form.

I'm on the main form. The main form consists of two subforms. I want to catch the editing of records on both. Let's say I changed data on the first subform and then I went to the next subform. I used LostFocus, DeActivate, Exit events but its not cathing the procedure for confirming the update. Only the AfterUpdate event catches them all. The problem is I have to do it two times to get out of the loop to go to the next subform.

On the first subform, there is a form's BeforeUpdate on all controls that if it is not equal to the OldValue property it will change a variable to true.

Dim C As Control
For Each C In Me.Controls
Select Case C.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup, acCheckBox
If C.Value <> C.OldValue Then
UpdateDone = True
End If
End Select
Next C

And now I'm trying to catch that by placing this code on the this subform's LostFocus and DeActivate but only works on AfterUpdate event and it prompts again after I select "No"

If ChangedData = True Then
ChangedData = False

Dim ans As Integer
ans = MsgBox("A record has been changed." & vbCrLf & vbCrLf & _
"Do you want to save it?", vbYesNo + vbQuestion, "Changed Records.")
If ans = vbYes Then

Me.Parent.txtAbout_UpdatedBy = fOSUserName
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
End If
Sep 13 '06 #1
Share this Question
Share on Google+
2 Replies

PEB
Expert 100+
P: 1,418
PEB
Hi,
Why do not try to add this code to each subform before update event?

And not for the totality of the form!

If it is for the totality you can't undo when there is multi records in the subform!

Have a nice day!
:)
Sep 13 '06 #2

PEB
Expert 100+
P: 1,418
PEB
gazelle04 Thank you!

Your thread about tracking changes and making undo of records was very usefull for me! :)

In fact i've seen for the first time the use of oldvalue property in before update event!

And I've used today! It does amazing job! And opens a lot my hands to do what I want! :)

Thank you!

:)

Vladimir
Sep 14 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.