Create a yes no message on a command button on click

Joined
Jan 29, 2018
Messages
1
Reaction score
0
I need to know the code I would use to show a user as per follows:
Userform is frmsale

1. user enters sale data
2, user clicks on command button (add revenue)
3. Message appears prompting them "Is the sales data entered correct?"
4. if yes then data is entered to specific worksheet and another message to user indicates Sales have been added.
5. If no the form is cleared and reset without data being added to specific worksheet and message displayed to user " Please re-enter Sales Data"

This is what I have and it works well, just can't work out how to do the messages.
Option Explicit

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("SSR Form")

'''find first empty row in database
''iRow = ws.Cells(Rows.Count, 1) _
'' .End(xlUp).Offset(1, 0).Row
'revised code to avoid problems with Excel tables in newer versions
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

'Enter Revenue'
If Trim(Me.txtD.Value) = "" Then
Me.txtD.SetFocus
MsgBox "Please enter Revenue Sales"
Exit Sub


End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtD.Value
ws.Cells(iRow, 2).Value = Me.txtCash.Value
ws.Cells(iRow, 3).Value = Me.txtEFT.Value
ws.Cells(iRow, 4).Value = Me.txtFunct.Value
ws.Cells(iRow, 5).Value = Me.txtOrders.Value


'clear the data
Me.txtD.Value = ""
Me.txtCash.Value = ""
Me.txtEFT.Value = ""
Me.txtFunct.Value = ""
Me.txtOrders.Value = ""
Me.txtD.SetFocus


End Sub

Private Sub cmdClose_Click()

Unload Me
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top