Solved

problem with a code vbyesnocancel on vba in access 2013

Posted on 2013-10-27
2
1,057 Views
Last Modified: 2013-10-27
hi

i have this code:

If Me.Closed = False And Not IsNull(Me.MecirahID) Then
    If MsgBox("do you want to close this form", vbYesNoCancel) = vbCancel Then
        Exit Sub
    ElseIf vbYes Then
        Me.Closed = True
    ElseIf vbNo Then
        Me.Closed = False
    End If
End If

Open in new window


but for some reason even when i click on the no in the msgbox it's  still  me.close=true
0
Comment
Question by:bill201
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39604524
Try this instead:
Dim intReturn

If Me.Closed = False And Not IsNull(Me.MecirahID) Then
    intReturn = MsgBox("do you want to close this form", vbYesNoCancel) 
    SELECT CASE intReturn
    Case vbCancel
        Exit Sub
    case vbYes 
        Me.Closed = True
    case vbNo 
        Me.Closed = False
    End Select
End If

Open in new window

0
 

Author Comment

by:bill201
ID: 39604541
it's  do not solved the problem, but i I found the solution what i change false to null

Anyway thanks alot for the efforts and therefore you deserve the points
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now