0
votes

I currently have a userform that has 3 options on printing. I want to be able to click a button, a msgbox appear with the options "yes" or "no" and if the user selects "yes", then run a sub program that's on sheet 4 (i have 2 sheets that are sheet4 and sheet2).I think the problem with the code right now is with "call slab", VBA inst recognizing the sub program "slab", this is the program that will print out my selected data.

Private Sub CommandButton1_Click()
  If MsgBox("Do you want to continue?" & vbCrLf, vbYesNo) = vbYes Then
  Call Slab
  Else
  docmd.Close commandButton_Click


  End Sub
1
...all VBA coders should read Chip Pearson's "everything" :-)ashleedawg

1 Answers

1
votes

Declare the slab as public and it will be ok:

Private Sub CommandButton1_Click()

    Select Case MsgBox("Do you want to continue?" & vbCrLf, vbYesNo)
        Case vbYes
            Slab
        Case vbNo
            'nothing
    End Select

End Sub

Public Sub Slab()
    MsgBox "Here is the SLAB"
End Sub