Hi. One way to do what you need to do is to check the name of the control returned by Screen.PreviousControl.
- Private Sub cmdFBSelection_Click()
-
Dim Ctrl as Control
-
Set Ctrl = Screen.PreviousControl
-
If Ctrl.Name <> "Mthfwd" then
-
MsgBox "your message"
-
Ctrl.Setfocus
-
Exit Sub
-
end if
-
DoCmd.RunCommand acCmdFilterBySelection 'Runs filter
-
End Sub
I am not convinced that this is the right way to go as all it shows is that the last control that had focus was the one mentioned. It does not show that a value has been updated. If you need to ensure that a value has been updated you could use the After Update event for that control to set a value accordingly, then test for this value in your selection code.
As an example, you could set the control's tag property (which is normally unused) to a text value in the control's After Update event code then test for that value in your selection click routine:
- Private Sub MthFwd_AfterUpdate()
-
Me!MthFwd.Tag = "Updated"
-
End Sub
- Private Sub cmdFBSelection_Click()
-
If Me!Mthfwd.Tag <> "Updated" then
-
MsgBox "your message"
-
Me!MthFwd.Setfocus
-
Exit Sub
-
end if
-
DoCmd.RunCommand acCmdFilterBySelection 'Runs filter
-
End Sub
Hope these ideas help.
-Stewart