Search code examples
ms-accessvbamessagebox

Second message box


This is my first bit of code that I've tried to do myself so please forgive any noob mistakes.

I'm trying to get a second message box to appear if no is selected on the first one but am having no luck. Any help would be great.

code as follows:

    Private Sub cmdUploadReady_Click()

Dim Msg, Style, Title, Help, Ctxt, Response, MyString

Msg = "Before Uploading Hole Data you must register you Work Program/POWE. Have you done this?"
Style = vbYesNo + vbCritical
Title = "Uploader"


Response = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then
'make pickers visible
Me.POWENumber_Label.Visible = True
Me.POWE_picker.Visible = True
Me.cmdUploadHoles.Visible = True


Else

Msg = "MsgBox do you wish to register now?"
        Style = vbYesNo + vbQuestion
        If Response = vbYes Then
        DoCmd.OpenForm "frmWorkPrograms_new"

        Else
        Cancel = True

        End If


End If

End Sub

Cheers in advance.


Solution

  • Try below code. Need to add this line Response = MsgBox(Msg, Style, Title, Help, Ctxt)

      Private Sub cmdUploadReady_Click()
    
            Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    
            Msg = "Before Uploading Hole Data you must register you Work Program/POWE. Have you done this?"
            Style = vbYesNo + vbCritical
            Title = "Uploader"
    
    
            Response = MsgBox(Msg, Style, Title, Help, Ctxt)
    
            If Response = vbYes Then
                'make pickers visible
                Me.POWENumber_Label.Visible = True
                Me.POWE_picker.Visible = True
                Me.cmdUploadHoles.Visible = True
    
    
            Else
    
                Msg = "MsgBox do you wish to register now?"
                Style = vbYesNo + vbQuestion
                Response = MsgBox(Msg, Style, Title, Help, Ctxt) '***Add this line****'
    
                If Response = vbYes Then
                    DoCmd.OpenForm "frmWorkPrograms_new"
    
                Else
                    Cancel = True
    
                End If
    
    
            End If