Next button problems

  • Thread starter spcscooter via AccessMonster.com
  • Start date
S

spcscooter via AccessMonster.com

I have a next button in a form that I have criteria for. I have a date field
that has to be entered before going to another record. When I click the next
button I get the pop up that says click update to continue but the form
displays the next record instead of staying on the current record that needs
updating. Here is the code that I am using.
____________________________________________________________________________________
Private Sub Command39_Click()
If IsNull([Post Called Customer]) Then
MsgBox "You must click the UPDATE button to continue!!!"
Cancel = True
End If

On Error GoTo Err_Command39_Click


DoCmd.GoToRecord , , acNext

Exit_Command39_Click:
Exit Sub

Err_Command39_Click:
MsgBox Err.Description
Resume Exit_Command39_Click

End Sub
________________________________________________________________________
Thank you for all your help!!!!!!!!
 
M

missinglinq via AccessMonster.com

Try this:

Private Sub Command39_Click()

On Error GoTo Err_Command39_Click

If IsNull([Post Called Customer]) Then
MsgBox "You must click the UPDATE button to continue!!!"
Cancel = True
Else
DoCmd.GoToRecord , , acNext
End If

Exit_Command39_Click:
Exit Sub

Err_Command39_Click:
MsgBox Err.Description
Resume Exit_Command39_Click

End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
A

Allen Browne

There are so many ways a record can be saved.
You are testing only via the click of your button.

Move the test into the BeforeUpdate event of the form instead:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull([Post Called Customer]) Then
MsgBox "You must enter the Post Called Customer."
Cancel = True
End If
End Sub

In the Click event of your command button, use:
RunCommand acCmdSaveRecord
RunCommand acCmdNextRecord
along with the error handler part.
 
S

spcscooter via AccessMonster.com

Thank you all very much. You have no idea how much this helps!!!
Try this:

Private Sub Command39_Click()

On Error GoTo Err_Command39_Click

If IsNull([Post Called Customer]) Then
MsgBox "You must click the UPDATE button to continue!!!"
Cancel = True
Else
DoCmd.GoToRecord , , acNext
End If

Exit_Command39_Click:
Exit Sub

Err_Command39_Click:
MsgBox Err.Description
Resume Exit_Command39_Click

End Sub
 
S

spcscooter via AccessMonster.com

Thank you all very much. You have no idea how much this helps!!!

Allen said:
There are so many ways a record can be saved.
You are testing only via the click of your button.

Move the test into the BeforeUpdate event of the form instead:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull([Post Called Customer]) Then
MsgBox "You must enter the Post Called Customer."
Cancel = True
End If
End Sub

In the Click event of your command button, use:
RunCommand acCmdSaveRecord
RunCommand acCmdNextRecord
along with the error handler part.
I have a next button in a form that I have criteria for. I have a date
field
[quoted text clipped - 25 lines]
________________________________________________________________________
Thank you for all your help!!!!!!!!

--
Scot Rawlings
Technical Trainer
Comcast
Auburn, WA

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top