I almost have this but not quite. I have a button that a user can click to take them to a detailed form but I don't want them to be able to go to the detailed form unless they populate something into a field called [Question]. The code I have below is working except that after displaying the message, I would like the user to be taken back to the [Question] field on the form. What am I missing? Thanks for any help.
Code:
Private Sub Command206_Click()
On Error GoTo Err_Command206_Click
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
If IsNull(Me!Question) Or Me!Question = "" Then
strMsg = "You must enter something in the Question field before going to the detail screen."
strTitle = "Question Text Missing"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
End If
RunCommand acCmdSaveRecord
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmMain"
stLinkCriteria = "[QuestID]=" & Me![QuestID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmMainTEST"
Exit_Command206_Click:
Exit Sub
Err_Command206_Click:
MsgBox Err.Description
Resume Exit_Command206_Click
End Sub