Yes/No Message Box

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,332
Office Version
  1. 365
Platform
  1. Windows
I would like to add a pop-up Message box that happens in this code after the DoCmd.RunCommand acCmdSaveRecord.

"Do you want to return to the TSL?"

If Yes then then DoCmd.OpenForm "frm_NIS_TSL", acNormal, "", "", , acNormal

If No then the DoCmd.GoToRecord , "", acNewRec command

Any help is appreciated.

Code:
Private Sub Command228_Click()
'Save Button
'Check Required Fields to verify data was entered


Dim strMissingInfo As String
Dim strMsg As String

On Error GoTo Command228_Click_Err

    On Error Resume Next
    
    
    If IsNull(Me.[Debarred]) Then
            MsgBox "You Must make a Selection in the Debarred Field"

    Else
    
    If IsNull(Me.[Restricted]) Then
            MsgBox "You Must make a Selection in the Resticted Field"
    Else

    If Me.[CommType].Value = "NA" Then
            MsgBox "You Must make a Selection in the Commodity Type Field"
    Else
    
    If Me.[Approval_Status].Value = "NA" Then
            MsgBox "You Must make a Selection in the Approval Status Field"
    Else
    
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord , "", acNewRec
    
    End If
    End If
    End If
    End If
    

    If (MacroError <> 0) Then
        Beep
        MsgBox MacroError.Description, vbOKOnly, ""
            End If


Command228_Click_Exit:
    Exit Sub

Command228_Click_Err:
    MsgBox Error$
    Resume Command228_Click_Exit

End Sub

Thanks for the Help!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
maybe
add Dim result As Integer in the declarations section

after the line in question:
Code:
result = Msgbox("Do you want to return to the TSL?",vbYesNo)
If result = vbYes Then 
  DoCmd.OpenForm "frm_NIS_TSL", acNormal, "", "", , acNormal
Else
  DoCmd.GoToRecord , "", acNewRec command
End If
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top