Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message box help

Status
Not open for further replies.

lkennemur

Programmer
Aug 19, 2005
32
0
0
US
I am trying to create some code that will bring up a message box. When a user types in a response I want them to click cmdSaveResponse and then click cmdNextQuestion. If the user doesn't click cmdSaveResponse, once they click cmdNextQuestion I want a message box to appear that tells them that they must first save their response.

Private Sub cmdNextQuestion_Click()
On Error GoTo Err_cmdNextQuestion_Click

If (Me!sfrmSurveyInfo.Form!cmdSaveResponse.OnClick = True) Then
DoCmd.GoToRecord , , acNext

ElseIf (Me!sfrmSurveyInfo.Form!cmdSaveResponse.OnClick = False) Then
MsgBox ("You must save your response before you proceed to the next question.")
End If




Exit_cmdNextQuestion_Click:
Exit Sub

Err_cmdNextQuestion_Click:
MsgBox Err.Description
Resume Exit_cmdNextQuestion_Click

End Sub

I know that my code isn't correct so any tips will be greatly appreciated.

Thanks!
 
The .Dirty property tells you whether any field has been changed. I use this
Code:
If Me.Dirty Then
  ' if edit in progress give user chance to recover
  If MsgBox("Abandon changes to this record?", vbYesNo + vbQuestion, "Confirm Action") = vbYes Then
     Me.Undo
     DoCmd.Close
   End If
Else
   DoCmd.Close
End If
to give the user the chance to save (or not) his changes.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Right now I have the form set up like this:

On a subform, I have a combo box for the user to select a response and a command button to save the response. If a response isn't selected the value of NA is automatically stored in the table. Once the user has saved the response, they must click the command button for next question on the main form. What I want is a way to ensure that the user does click the command button to save the response before clicking the command button to go to the next question.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top