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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save Code 1

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I am using the following code to have a pop up box come up if a field is left blank reminding the user to fill out that field, if the field is filled in it should save the record and then go to a new record, but when the field is blank the pop up is displayed but when you click on OK it just goes to a new record skipping the cancel string....can anyone help me?

Code:
Private Sub Command34_Click()
If (IsNull(other)) And [Reason] = "other" Then
        MsgBox "Please provide 'Other' explanation", vbExclamation
        Cancel = True
    End If
    
If (IsNull(other)) And [Reason] = "Not cd related" Then
        MsgBox "Please provide 'Not CD Related' explanation", vbExclamation
        Cancel = True
    End If
    
    
    DoCmd.Save
    DoCmd.GoToRecord , , acNewRec
    
    
    
    

End Sub
 
Thank you Remou, if I put that in the before update of the form then it gives me an error after i click on ok that says "You cant go to that specific Record" i assume because its trying to go to a new record...is there a way to suppress it from getting the VB error and just go back to the form?

Thanks again for your help!

Paul
 
I did not explain that well. Use the before update event to validate the form. The button can still be used to go to a new record.
 
If (IsNull(other)) And [Reason] = "other" Then
MsgBox "Please provide 'Other' explanation", vbExclamation
[!]Exit Sub[/!]
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you all for the help.....

PHV that did the trick! thank you so much!!!

Pau
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top