ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MsgBox responce If statment (https://www.excelbanter.com/excel-programming/420600-msgbox-responce-if-statment.html)

Dave[_9_]

MsgBox responce If statment
 
seems I can't get an IF statement based upon the response from a msgbox
function

This is what I have

Code:

        MsgBox "This will delete all information on this caller" & vbLf & _
    "Are you sure you want to do this", vbYesNo
    If vbYesNo = Yes Then
        Me.FirstName.Value = ""
        Me.LastName.Value = ""
        Me.Caller.Value = ""

      Else
        Exit Sub
      End If
    Me.Status = 4
    DoCmd.Close

If I hit YES it does not delete the info.

should the IF statement be true/false or 0/1 instead of Yes/No?

Is the MsgBox written wrong?

Any help here will be appreciated.

Thanks in advance
dave


Charlotte E.[_2_]

MsgBox responce If statment
 
Try this:


If MsgBox("This will delete all information on this caller" & vbLf & "Are
you sure you want to do this", vbYesNo) = vbYes then
Me.FirstName.Value = ""
Me.LastName.Value = ""
Me.Caller.Value = ""
Else
Exit Sub
End If



Dave wrote:
seems I can't get an IF statement based upon the response from a
msgbox function

This is what I have

Code:

        MsgBox "This will delete all information on this caller" &
    vbLf & _ "Are you sure you want to do this", vbYesNo
    If vbYesNo = Yes Then
        Me.FirstName.Value = ""
        Me.LastName.Value = ""
        Me.Caller.Value = ""

      Else
        Exit Sub
      End If
    Me.Status = 4
    DoCmd.Close



If I hit YES it does not delete the info.

should the IF statement be true/false or 0/1 instead of Yes/No?

Is the MsgBox written wrong?

Any help here will be appreciated.

Thanks in advance
dave




Dave[_9_]

MsgBox responce If statment
 
Thank you.

That did the trick

Dave

"Charlotte E." <@ wrote in message
...
Try this:


If MsgBox("This will delete all information on this caller" & vbLf & "Are
you sure you want to do this", vbYesNo) = vbYes then
Me.FirstName.Value = ""
Me.LastName.Value = ""
Me.Caller.Value = ""
Else
Exit Sub
End If



Dave wrote:
seems I can't get an IF statement based upon the response from a
msgbox function

This is what I have

Code:

        MsgBox "This will delete all information on this caller" &
    vbLf & _ "Are you sure you want to do this", vbYesNo
    If vbYesNo = Yes Then
        Me.FirstName.Value = ""
        Me.LastName.Value = ""
        Me.Caller.Value = ""

      Else
        Exit Sub
      End If
    Me.Status = 4
    DoCmd.Close



If I hit YES it does not delete the info.

should the IF statement be true/false or 0/1 instead of Yes/No?

Is the MsgBox written wrong?

Any help here will be appreciated.

Thanks in advance
dave





All times are GMT +1. The time now is 09:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com