I am relatively new to access forms and have a question. I have a bound subform which I would like to have data edits and bring the focus back to the incorrect field.. As an example, if I leave the award field as '0', the error message displays "Must enter award amount". When I click "OK", I want to bring the user back to the award field on the form. Right now after I click OK - it flows through to "ready to save this record? Yes/No".
Private Sub Command17_Click()
Dim strLocation As String
Me.Modified_by = Environ("USERNAME")
Me.Modified_on = Format(Now(), "yyyy-MM-dd hh:mm:ss")
Me.AwardType = "Sales - Top Award"
If [Award] = 0 Then MsgBox ("Must enter award amount.") ' when there is an error, how to set focus back in the form to this field after they click ok?
If [Year_Earned] = 0 Then MsgBox ("Must enter year.") Else ' same -- how to set focus back to year-earned after they click ok?
Const cstrprompt As String = "Ready to save this record? Yes/No" ' if they select no, then I want to stay on the form and set focus on a specific field?"
If MsgBox(cstrprompt, vbQuestion + vbYesNo) = vbNo Then
Cancel = False
End If
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
DoCmd.OpenForm FormName:="frm_advisorhomepage"
exit_cmdcommand17_click:
Exit Sub
End Sub
Private Sub Command17_Click()
Dim strLocation As String
Me.Modified_by = Environ("USERNAME")
Me.Modified_on = Format(Now(), "yyyy-MM-dd hh:mm:ss")
Me.AwardType = "Sales - Top Award"
If [Award] = 0 Then MsgBox ("Must enter award amount.") ' when there is an error, how to set focus back in the form to this field after they click ok?
If [Year_Earned] = 0 Then MsgBox ("Must enter year.") Else ' same -- how to set focus back to year-earned after they click ok?
Const cstrprompt As String = "Ready to save this record? Yes/No" ' if they select no, then I want to stay on the form and set focus on a specific field?"
If MsgBox(cstrprompt, vbQuestion + vbYesNo) = vbNo Then
Cancel = False
End If
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
DoCmd.OpenForm FormName:="frm_advisorhomepage"
exit_cmdcommand17_click:
Exit Sub
End Sub