Message Boxes

What's wrong with the following code:

Private Sub cmdDelete_Click()

Response = MsgBox("Do you want to DELETE the current record.", vbYesNo + vbExclamation + vbDefaultButton2, "Warning")
         
If Responce = vbYes Then
    frmFormName.datacontrol.Recordset.Delete
    frmFormName.datacontrol.Refresh
Else
    Exit Sub
End If

End Sub

When the 'Yes' button is clicked nothing happens, but without the message box the 'frmFormName.datacontrol.Recordset.Delete' works OK. So its not detecting that the Yes button has been clicked.

Any clues?
LVL 1
ncwAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
Response is misspelled in the If statement

Always use Option Explicit at the top of your code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
foxhoundCommented:
which also prevents u from not diming your variables
0
caraf_gCommented:
Yes! ncw, go into your VB menu now: Tools-Options. On the first tab "Editor" you'll see "Require variable declaration". Switch it on and never switch it off again. In all the code you've written so far, re-visit the code modules and make sure that Option Explicit is the first line in ALL of them.

After six versions of VB, I cannot for the life of me understand why Micro$oft have still made having this check box turned off the default setting. I've seen professional applications that are used world wide crumble in a heap because of this, so don't feel too bad about it ;-)

Erick37's response is right on the button, so his answer is excellent.
0
ncwAuthor Commented:
Yes I had missed that simple spelling mistake.

I normally do put Option Explicit in the top of the declarations section but this time I had forgotten to do so.

I have now changed the setting in made Tools-Options.

Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.