If a user chooses no on a msg box prompt I want the focus to go back to the control that the user was updating. I don't get any errors but the focus doesn't get set back to the control. Both controls are on a subform and i have tried the DoCmd.GotoControl to setfocus on the subform before setfocus to the completed date control but that does the same thing.
Here is my code:
Private Sub Completed_Date_AfterUpdate()
'if the fbm is earlier than the comp date entered, ask user if they want to set the first billable month to new date specified by completed date.
If Me.First_Billable_Month.Value > Me.Completed_Date.Value Then
Dim Msg, Style, Title, Help, Ctxt, response, MyString
Msg = "The date you have specified is earlier than the First Billable Month. Do you want to overwrite the First Billable Month?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "First Billable Month"
response = MsgBox(Msg, Style, Title)
If response = vbYes Then ' User chose Yes.
MyString = "Yes"
Me.First_Billable_Month.Value = Me.Completed_Date.Value
Else
MyString = "No" ' User chose No.
Me.Completed_Date.Value = ""
Me.Completed_Date.SetFocus
End If
End If
End Sub
Maybe I should put this code in the event proc for On Dirty instead?
Here is my code:
Private Sub Completed_Date_AfterUpdate()
'if the fbm is earlier than the comp date entered, ask user if they want to set the first billable month to new date specified by completed date.
If Me.First_Billable_Month.Value > Me.Completed_Date.Value Then
Dim Msg, Style, Title, Help, Ctxt, response, MyString
Msg = "The date you have specified is earlier than the First Billable Month. Do you want to overwrite the First Billable Month?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "First Billable Month"
response = MsgBox(Msg, Style, Title)
If response = vbYes Then ' User chose Yes.
MyString = "Yes"
Me.First_Billable_Month.Value = Me.Completed_Date.Value
Else
MyString = "No" ' User chose No.
Me.Completed_Date.Value = ""
Me.Completed_Date.SetFocus
End If
End If
End Sub
Maybe I should put this code in the event proc for On Dirty instead?