[Webinar] Streamline your web hosting managementRegister Today


Message Boxes

Posted on 1999-11-01
Medium Priority
Last Modified: 2010-05-02
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
    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?
Question by:ncw
LVL 32

Accepted Solution

Erick37 earned 80 total points
ID: 2175282
Response is misspelled in the If statement

Always use Option Explicit at the top of your code.

Expert Comment

ID: 2176139
which also prevents u from not diming your variables
LVL 10

Expert Comment

ID: 2176678
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.

Author Comment

ID: 2188929
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question