Solved

Actioning vbNo ad well as vbYes on msgbox.

Posted on 2013-11-04
3
303 Views
Last Modified: 2013-11-04
This is probably quite simple but looking for some guidance. This code works fine and just cancels a given action if the user presses No on the msgbox:

If MsgBox("This quotation will be cancelled and you will be unable to convert it to an an order, nor will it appear on the quotations list. Do you want to continue?", vbQuestion + vbYesNo, "GBIS") = vbYes Then
    Me.orderstatus.Value = "Cancelled"
    MsgBox "This quotation has been cancelled. This screen will now close.", vbInformation, "GBIS"
    DoCmd.Close
    End If
    
GoTo lastline

Open in new window


I want to add something like:

if vbno then me.textbox.value = ""

Just to clear out a text box and abort the actions which are taken when yes is pressed.

All help appreciated.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39621427
Try this:

Dim lngResponse
lngResponse = MsgBox("This quotation will be cancelled and you will be unable to convert it to an an order, nor will it appear on the quotations list. Do you want to continue?", vbQuestion + vbYesNo, "GBIS")

Select Case lngResponse 
case  vbYes 
    Me.orderstatus.Value = "Cancelled"
    MsgBox "This quotation has been cancelled. This screen will now close.", vbInformation, "GBIS"
    DoCmd.Close
Case vbNo
    me.textbox.value = ""

Case Else ' User clicked x button
     ' Do something

end select
      
GoTo lastline 

Open in new window

0
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 39621449
@mbizup

by vbYesNo the Cancel "X" button is disabled no need to implement an else case

Regards
0
 

Author Closing Comment

by:Computer_Support_Norwich
ID: 39621509
mbizup.... right on the money, thanks.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

734 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