Message Box vbYes

speakers_86

Registered User.
Local time
Today, 03:37
Joined
May 17, 2007
Messages
1,919
I got this code, but the vbYes doesn't want to work. It keeps acting like I am saying vbNo. I got the format for working with message boxes from here. What doesn't make sense to me is that the link says to declare the variable as an integer, but I am storing string there. I tried setting LResponse = 6, but same result.

Code:
Private Sub Check152_AfterUpdate()

'Warn user before data is deleted.
If Me.Check152.Value = 0 Then
    If IsNull(Me.TCL) Then
        Else
        Dim LResponse As Integer
        LResponse = MsgBox("You will loose data if you click 'OK'.", vbOKCancel, "Continue?")
        If LResponse = vbYes Then
            Me.TCL.Value = Null
            Me.TCL.Enabled = False
            Me.TCR.Value = Null
            Me.TCR.Enabled = False
            Else
            Me.Check152.Value = -1
        End If
    End If
    Else
    Me.TCL.Enabled = True
    Me.TCR.Enabled = True
End If
'''''''''''''''''''''''''''''''''''''''''''''''''
 
I swear I didn't change anything, but it works now. :(

I did change vbOk to vbCancel just to play with it. With vbCancel, it worked as expected (of course backwards though), then I put it back to vbOk, and it is fine.
 
According to you code you set up your message box with the buttons OK (1) and Cancel (2). But you tested for vbYes. The response can't be vbYes - only vbOk and vbCancel. So your test would always be false.

Chris
 

Users who are viewing this thread

Back
Top Bottom