Yes/No Message Box

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,690
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!
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,803
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
 

Forum statistics

Threads
1,089,381
Messages
5,407,923
Members
403,171
Latest member
mayesmail12

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top