Re: Me.Dirty - not catching changes

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thank you for your response. I am having problems finding the Exit event.
Is this same as "lostfocus", "deactivate" or "unload". I don't find
anything for "Exit". Any further help appreciated.

Thank you.






"Steve Schapel" <schapel@xxxxxxxxxxx> wrote in message
news:OubvS2PzFHA.2848@xxxxxxxxxxxxxxxxxxxxxxx
> DJW,
>
> When you move the focus to another tab page, it is too late at this point
> to be testing the Dirty property of the subform. You have already left
> trhe subform, and when you do that, any changes are saved automatically,
> so by the time you arrive at the next destination the subform is not dirty
> any more. Maybe it would be applicable to put your code on the subform's
> Exit event?
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> DJW wrote:
>> I have a form with a tab control and three pages (tabs) under that
>> control. Each page has a subform on it.
>>
>> What I'm trying to do is check all the controls located on the subform on
>> page 2 for any changes (dirty) when I click on another tab (page).
>>
>> I have code now that catches any changes when I click on controls
>> (previous record, next record, add record) located within the subform
>> located on page 2. However, when I "dirty the record" and then click on
>> another tab, it does not catch the changes and apparently saves the
>> changes as when I click back to page 2 the changes are still present.
>>
>> Below is the code I have for checking the controls on page 2 (subform
>> name is 'frmsub_Evidence'). This code runs within the subform. I want
>> to run it when I leave the subform and click on another tab. Where do I
>> place the code to do this? Any help appreciated.
>>
>>
>>
>>
>> If Me.Dirty Then 'Checks if any changes were made.
>> GoTo Question
>> Else
>> GoTo Step3
>> End If
>>
>> Question:
>> Message = "Changes made! Do you wish to save?" 'Gives
>> option to save changes.
>> If MsgBox(Message, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
>> GoTo Step1
>> Else
>> DoCmd.RunCommand acCmdUndo 'Undoes any changes.
>> GoTo Step4
>> End If
>>
>> Step1: 'Check to make sure all required fields contain information.
>> If IsNull(Me![Case Number]) Then
>> MsgBox "What is the Case Number?"
>> Me![Case Number].SetFocus
>> ElseIf IsNull(Me![Submitted As]) Then
>> MsgBox "The Item was Submitted as what?"
>> Me![Submitted As].SetFocus
>> ElseIf IsNull(Me![Date Submitted]) Then
>> MsgBox "When was the Item Submitted?"
>> Me![Date Submitted].SetFocus
>> ElseIf Not IsNull(Me![Removal Date]) Then
>> GoTo Step2
>> Else
>> GoTo Step3
>>
>> Step2:
>> If IsNull(Me![Released By]) Then
>> MsgBox "Enter intials of Tech releasing the property."
>> Me![Released By].SetFocus
>> ElseIf IsNull(Me![Requested By]) Then
>> MsgBox "Which employee is requesting this item?"
>> Me![Requested By].SetFocus
>> ElseIf IsNull(Me![Reason For Removal]) Then
>> MsgBox "Specify the reason the item was removed."
>> Me![Reason For Removal].SetFocus
>> ElseIf IsNull(Me![Recieved By]) Then
>> MsgBox "Who Recieved the Item?"
>> Me![Recieved By].SetFocus
>> Me![Record Updated By] = LoginNameField 'Enters variable value of
>> LoginNameField.
>> Else
>> GoTo Step3
>>
>> Step3:
>>
>> ' DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
>> acMenuVer70 'Saves record.
>> DoCmd.RunCommand acCmdRefresh 'Refreshes record to show change after
>> save.
>> Me.Repaint 'Repaints the screen to show updated record.
>> GoTo Step4
>>
>> Step4:
>> 'Do Nothing
>>
>> Exit Sub
>>
>> End If
>> End If
>>
>>
>>
>>

.


Quantcast