PDA

View Full Version : [SOLVED:] Want VBA Textbox information to show VBA MsgBox



dharvey
01-23-2021, 05:32 PM
Hi,

I am wondering if it is possible to have a VBA msgbox to show information from a Textbox that's in a VBA Userform. The text I have below works upto the point of where I what it to call "Are you sure you want to Confirm this Quantity" (The last step). What I want it to do is to read the textbox 3 value and display it in the message box. Is this possible or do I just give up on this or is there a code that will enable this to work.



Private Sub CommandButton2_Click()

If Me.TextBox2.Value = "" Then
MsgBox "Please add a product into product box"
Exit Sub
End If


If IsNumeric(Me.TextBox3.Value) = False Then
MsgBox "Invalid Qty"
Exit Sub
End If

Dim Answer As VbMsgBoxResult


Answer = MsgBox("Are you sure you want to Submit this Entry", vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Submission")

If Answer = vbYes Then

Answer = MsgBox("Are you sure you want to Confirm this Quantity" & vbLf & _
IsNumeric(Me.TextBox3.Value).Text, vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Quantity")
Exit Sub
End If

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Stock In-Out")


Dim lr As Long
lr = Application.WorksheetFunction.CountA(sh.Range("A:A"))


sh.Range("A" & lr + 1).Value = Me.TextBox2.Value




If Me.OptionButton1.Value = True Then
sh.Range("B" & lr + 1).Value = "IN"
Else
sh.Range("B" & lr + 1).Value = "OUT"
End If


sh.Range("C" & lr + 1).Value = Me.TextBox4.Value
sh.Range("D" & lr + 1).Value = Me.TextBox3.Value
sh.Range("E" & lr + 1).Value = Me.TextBox6.Value


MsgBox "Updated!!!"






End Sub

Thanks

Paul_Hossler
01-23-2021, 07:10 PM
Just guessing here

Post a small sample workbook to be a better answer



Dim Answer As VbMsgBoxResult
Answer = MsgBox("Are you sure you want to Submit this Entry", vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Submission")

If Answer = vbYes Then
Answer = MsgBox("Are you sure you want to Confirm this Quantity" & vbLf & _
Format(Me.TextBox3.Text, "#,##0"), vbYesNo + vbQuestion + vbDefaultButton2, "Confirmation of Quantity")
If Answer = vbNo Then Exit Sub
End If

dharvey
01-23-2021, 07:19 PM
Thanks Paul_Hossler, that has work marvellously.

Thanks for your help

Thanks
Donald