Msgbox cancel button

Hello!

I'm fairly new to Access and VB and I've been getting along alright
but I've run into a problem with a message box I set up in my form.

Situation:  the field FvsNF will always be filled out.  Depending on
the answer (yes or no) certain fields become enabled or disabled.  The
problem is if a user decides to change their answer for FvsNF after
filling out the wrong fields.  The incorrect fields need to go back to
zero if they decide to proceed with that action.  However if they
don't want to proceed I want to give them an out without losing their
entries.  The code I have now is:

Private Sub FvsNF_BeforeUpdate(Cancel As Integer)
Result = MsgBox("Warning: All values in section will become zero.",
vbOKCancel)
    If vbOK Then
        TotalCC.Value = 0
        OSCC.Value = 0
        Clumpiness.Value = 0
        ClumpDensity.Value = 0
        ClumpSize.Value = 0
        CrownDiff.Value = 0
        CanopyLayers.Value = 0
        Logging.Value = 0
        pcc.Value = 0
        DensOS.Value = -99
        DensUS.Value = -99
        sizeOS.Value = 0
        sizeUS.Value = 0
        sppOS.Value = 0
        sppUS.Value = 0
        Nonforesttype.Value = 0
        ElevBelt.Value = 0
        nonforestsppOS.Value = 0
        nonforestOSCC.Value = 0
        treecovergstype.Value = 0
        Else

    End If
End Sub

I've tried a lot of things under Else...and lots of different
combinations but I can't seem to get the cancel button to cancel!  Any
help would be greatly appreciated!

Kali

0
stoehrkr
6/15/2007 9:47:20 PM
access.forms 6864 articles. 2 followers. Follow

6 Replies
589 Views

Similar Articles

[PageSpeed] 29

Me.UnDo will return all of the controls to the values last saved.

stoehrkr@gmail.com wrote:
>Hello!
>
>I'm fairly new to Access and VB and I've been getting along alright
>but I've run into a problem with a message box I set up in my form.
>
>Situation:  the field FvsNF will always be filled out.  Depending on
>the answer (yes or no) certain fields become enabled or disabled.  The
>problem is if a user decides to change their answer for FvsNF after
>filling out the wrong fields.  The incorrect fields need to go back to
>zero if they decide to proceed with that action.  However if they
>don't want to proceed I want to give them an out without losing their
>entries.  The code I have now is:
>
>Private Sub FvsNF_BeforeUpdate(Cancel As Integer)
>Result = MsgBox("Warning: All values in section will become zero.",
>vbOKCancel)
>    If vbOK Then
>        TotalCC.Value = 0
>        OSCC.Value = 0
>        Clumpiness.Value = 0
>        ClumpDensity.Value = 0
>        ClumpSize.Value = 0
>        CrownDiff.Value = 0
>        CanopyLayers.Value = 0
>        Logging.Value = 0
>        pcc.Value = 0
>        DensOS.Value = -99
>        DensUS.Value = -99
>        sizeOS.Value = 0
>        sizeUS.Value = 0
>        sppOS.Value = 0
>        sppUS.Value = 0
>        Nonforesttype.Value = 0
>        ElevBelt.Value = 0
>        nonforestsppOS.Value = 0
>        nonforestOSCC.Value = 0
>        treecovergstype.Value = 0
>        Else
>
>    End If
>End Sub
>
>I've tried a lot of things under Else...and lots of different
>combinations but I can't seem to get the cancel button to cancel!  Any
>help would be greatly appreciated!
>
>Kali

-- 
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200706/1

0
ruralguy
6/15/2007 10:07:42 PM
Kali,

I assume you meant:

If Result = vbOK then
  ' Do something
Else
  ' Do something else
End If

Or you can combine it in the If statement such as:

If MsgBox("Warning: All values in section will become zero.", vbOKCancel) = 
vbOK then
  ' Do something
Else
  ' Do something else
End If

Or if you have more options you can also use the Select Case as in:

Select Case MsgBox("Do you really want to do this?", vbYesNoCancel + 
vbQuestion, "Do this Confirmation")
Case vbYes:
  ' Yes - Do something
Case vbNo:

  ' No -Do something
 Case Else

  ' Cancel - Do something
End Select

Or

Select Case MsgBox("Do you really want to do this?", vbYesNoCancel + 
vbQuestion, "Do this Confirmation")
Case vbYes:
  ' Yes - Do something
Case vbNo:

  ' No -Do something
Case Cancel

  ' Cancel - Do something
Case Else
   (Note. this action should never be taken for the above statement, but it 
is generally good practice to include an Else for more complex scenarios)
  ' Else - Do something
End Select

Of course Me.Undo will also work, if returning to your last set of saved 
values is your intention.

Hope this helps
Guy

<stoehrkr@gmail.com> wrote in message 
news:1181944040.182024.76900@n15g2000prd.googlegroups.com...
> Hello!
>
> I'm fairly new to Access and VB and I've been getting along alright
> but I've run into a problem with a message box I set up in my form.
>
> Situation:  the field FvsNF will always be filled out.  Depending on
> the answer (yes or no) certain fields become enabled or disabled.  The
> problem is if a user decides to change their answer for FvsNF after
> filling out the wrong fields.  The incorrect fields need to go back to
> zero if they decide to proceed with that action.  However if they
> don't want to proceed I want to give them an out without losing their
> entries.  The code I have now is:
>
> Private Sub FvsNF_BeforeUpdate(Cancel As Integer)
> Result = MsgBox("Warning: All values in section will become zero.",
> vbOKCancel)
>    If vbOK Then
>        TotalCC.Value = 0
>        OSCC.Value = 0
>        Clumpiness.Value = 0
>        ClumpDensity.Value = 0
>        ClumpSize.Value = 0
>        CrownDiff.Value = 0
>        CanopyLayers.Value = 0
>        Logging.Value = 0
>        pcc.Value = 0
>        DensOS.Value = -99
>        DensUS.Value = -99
>        sizeOS.Value = 0
>        sizeUS.Value = 0
>        sppOS.Value = 0
>        sppUS.Value = 0
>        Nonforesttype.Value = 0
>        ElevBelt.Value = 0
>        nonforestsppOS.Value = 0
>        nonforestOSCC.Value = 0
>        treecovergstype.Value = 0
>        Else
>
>    End If
> End Sub
>
> I've tried a lot of things under Else...and lots of different
> combinations but I can't seem to get the cancel button to cancel!  Any
> help would be greatly appreciated!
>
> Kali
> 


0
Guy
6/16/2007 12:38:31 AM
Hmmm...
Thank you for the suggestions but I'm still having problems.  I think
I need what the "do something" code is for making it cancel because I
can't make my code do anything but return all of the values to zero no
matter which button I choose (OK or Cancel).

Could I be doing something wrong with Me.undo?  It doesn't seem to be
doing anything at the moment.

I'll keep playing around with it but if you have any other suggestions
I'm all ears!

Thanks again,
Kali

0
stoehrkr
6/18/2007 2:17:14 PM
Have you single stepped the code to make sure it is executing?  Me.UnDo is
useless after you have saved the record.  What values are in the table that
the controls should return to.  If the controls are *not* bound to fields in
the underlying table/query then Me.UnDo will not work.

stoehrkr@gmail.com wrote:
>Hmmm...
>Thank you for the suggestions but I'm still having problems.  I think
>I need what the "do something" code is for making it cancel because I
>can't make my code do anything but return all of the values to zero no
>matter which button I choose (OK or Cancel).
>
>Could I be doing something wrong with Me.undo?  It doesn't seem to be
>doing anything at the moment.
>
>I'll keep playing around with it but if you have any other suggestions
>I'm all ears!
>
>Thanks again,
>Kali

-- 
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200706/1

0
ruralguy
6/18/2007 2:31:09 PM
Yes, I figured out that I need it to return to the values the user has
just entered not the ones that were last saved (It was returning to
zero which was the last saved record.  It confused me at the time).  I
got it to work by using  FvsNF.undo, it keeps the last values but
unfortunately it still switches the focus and enables the wrong set of
options for a user who canceled.

0
stoehrkr
6/18/2007 2:52:47 PM
Alright- I'm deleting my message box and hoping the user of this form
know's what they're doing...they'll learn quickly if they don't!
Thanks to all for your help!
Kali

0
stoehrkr
6/18/2007 5:46:19 PM
Reply:

Similar Artilces:

Sorting filtered list on form with a Command Button
I have a form CLIENTLIST. When I open this form it runs the query qryClientLst. One of the fields in the query named ClientID has the criteria "Like [Enter Client Number]". When I open the form CLIENTLIST I'm prompted to "Enter Client Number". When I do the form opens and only the files with the client number I entered appear. So basically it's a filtered form. All of this works fine. I created a command button above the column ClientId on my form so my users can click on the button and sort Ascending or Descending. Below is my code for this. My only...

grouping of option buttons
I'm using Excel 2003. I have grouped option buttons in several sheets of a workbook. They should contain the same information redundant in each sheet. This means if I set a button on one sheet, the corresponding buttons on the other sheets should be set, too. They all have the same groupname and the captions are the same in all sheets. Is it possible to use LinkedCell and how? Example: Sheet 1: OptionButton1: Caption "a", GroupName "g1" OptionButton2: Caption "b", GroupName "g1" Sheet 2: OptionButton3: Caption "a", GroupNam...

Adding buttons to phone call toolbar?
Can't see to find it in the SDK but can you use ISV.Config to add new buttons on to the phone call (activity) screens? I've created a series of phone call records related to invoices (one each). When an admin person calls the customer they are typically dealling with more then one invoice on the call. What we'd like to do is update all invoice phone calls with one copy of the phone call (instead of manually creating one record for each invoice). So we're thinking some kind of apply button which pop's up and selects the invoice records and on save creates copies of ...

Buttons/TABS
Hi I am updating a performance board which has buttons which link into other sheets in the same book although these are not visible on the sheet. I want to create another button/sheet. How do I do this please. Much Appreciated ...

Navigation Button Help
Hi.. I need some help how can i get the number which is shown at the Navigation Buttom at the bottom of the form in a report with other fields??? Is it possible?? thanks The number shown in the Nav Buttons at the bottom of a form is not consistent. It changes, depending on how the records are sorted, filtered, or when new records are added or old ones deleted. It is therefore not something consistent, so you cannot match it in a report. If you just want to number the records in your report (similar to the way the Nav Buttons number the records in a form), it's very easy. See: ...

Autoselect one of the two radio buttons
HI, I have a group of two radio buttons on a dialog in MFC MSVC 6.0 I need to autoselect one of them when application starts,,, Kindly suggest... also where does the code for the radio buttons instances and its related properties lies... thanks... a.a.cpp Assuming you've connected a variable to it via DDX called m_btnRadio, m_btnRadio.SetCheck(1); .....will check it. "iceColdFire" <icoldfire@yahoo.com> wrote in message news:1115790454.842600.218050@o13g2000cwo.googlegroups.com... > HI, > > I have a group of two radio buttons on a dialog in MFC MSVC 6.0 &...

Greying out buttons/menu in .NET
Can any one offer advice (particularly if this is the wrong forum to be posting this question in) on how using VC++ .NET to take 'focus' of a button and its associated menu item on selection of another button and its associated menu item. For example, I have two projects one being Single doc and the other a dialog based. They each do the same thing, however on selection of Button A (or its corresponding menu Item in Single doc): 1. In the single document I need to take focus (i.e. Grey out) off 3 buttons on the toolbar and their corresponding menu items. 2. Same above for the di...

Sales for outlook appointment button
Hi The CRM appointment button does not work. When we click on it, there is no action. We uninstall sales for outlook and reinstall. For 1-2 days, CRM appointment button works. After 1-2 days, it does not work again. There is a patch named CRM1.2-KB892949-Client-ENU. I applied it. Before I installed this fix, I had to change language ID to 1033 thru regedit. But, CRM appointment does not work. I tried this fix to 3 more clients but it does not work. Is it a bug which has not been solved ? Rgds. Clear your Outlook Forms cache and the buttons will start working again..Have a look at the...

attacment button
The attachment button doesnt work but "insert file" does work. And we are all happy for you. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the Swen virus, all e-mails sent to my actual account will be deleted w/out reading. After searching google.groups.com and finding no answer doug <anonymous@discussions.microsoft.com> asked: | The attachment button doesnt work but "insert file" does | work. ...

How to provide hotkey to system default HELP button?
Hi, I want to provide hotkey to the system's default 'Help' button. Could anyone help me in that? Thanks, -Varada Which help button are you talking about? -- Vipin Aravind MVP "Varada" <kvarada@gmail.com> wrote in message news:1137068622.901340.90100@g49g2000cwa.googlegroups.com... > Hi, > > I want to provide hotkey to the system's default 'Help' button. Could > anyone help me in that? > > Thanks, > -Varada > Here is one way. Press WinKey+F1 WINVER must be set to at lease 0x0410 (windows 98) for this to work. /...

No page navigation buttons
My page navigation buttons have disappeared in MS Publisher 2007. Can someone please tell me how to get them back? Go here, you need to do the registry fix for the page sorter. It is the sixth FAQ http://ed.mvps.org/Static.aspx?=Publisher/FAQs -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "resta" <resta@discussions.microsoft.com> wrote in message news:8FABC575-0232-415C-9029-B22792B3098F@microsoft.com... > My page navigation buttons have disappeared in MS Publisher 2007. Can someone > please tell me how to g...

save as isnt there neither is the save button pressable
hi my speradsheets will not let me save as or click the save button only way i can save is by ctrl +s i reallly need my save as to come back!!! SORT ME OUT Your best bet is to reset the buttons that seem to have got los somehow. Go to TOOLS, CUSTOMISE and select the tab COMMANDS. Go to FILE and i the right hand pane select the button you want and DRAG it across ont your toolbar and drop it. You can do this with any of the other button you like the look of. When you're through, close the dialog box an everything should be beck to normal Jo -- Jon Quixle ------------------------------...

save as report button
Greetings, If Access 2000 there was a button I could add to the form toobar that would save the form as a report. I can't find it in Access 2007. Please help! You would have to build the report the use the button to open the report and then print it. Otherwise, you are just printing the FORM not the REPORT. -- Milton Purdy ACCESS State of Arkansas "Joseph W Card" wrote: > Greetings, > > If Access 2000 there was a button I could add to the form toobar that > would save the form as a report. I can't find it in Access 2007. Please he...

Can I easily add an add sender to blocked senders button to Outlook 2003
I have XP Pro SP3 and Outlook 2003. If I see a new message in my inbox and know it is SPAM or want to add the sender to my blocked senders list, I have to right click the message, scroll down to junk email, choose add to blocked senders.... It works fine, but too many steps. I would like to just have the message highlighted and the simply click a toolbar button or something to mark it as SPAM and add it to the blocked senders. My built in filtering and all works fine, I am just trying to reduce this operation down to one click. Yahoo! mail has the Spam button that allows this. I am not to...

Catch click event button
Hi all, I was wondering... Is it possible to "catch" a click-event on a BuildIn Offie Button? In order to execute your own VBA-code? e.g. I want to be able to catch the "Undo" button in order to execute a piece of macro code in stead of just "Undoing" only the last action. Greetz, Bert -- Neron It is possible to catch ("intercept") most built-in Word commands, as described at http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm. In this case, the macro you need to write is named EditUndo, as in Public Sub E...

Button on Form to Add more rows
I have a form that I have created in excel and in one section of that form, I want to be able to add a button that will add 5 more rows for that specific section. The form is protected as there is some pretty heavy formulas and direct links to databases that update info for the form, so of course users cannot add rows themselves - is there a way to add a button that will allow users to add more rows to the form? -- Susan M. Project Controls Data Coordinator Susan Paste this macro into a standard module, then create the button you want and assign this macro to that butto...

Pictures dont display in emails but do when i hit the forward button.....
I have a problem with a few users at my company that pictures embeded in emails do not display in the regular view but when they click forward it shows up fine. Why is this occuring and how do i fix it? i have gone to microsofts site and tried several methods that they have suggested and still nothing resolve the problem. Outlook 2003 on windows xp pro thanks what mail server and is outlook fully updated? What things have you tried already? -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beg...

Where are the pivottable chart buttons?
In Excel 2003, If you made a graph of a pivot table you would have buttons inside the graph that would allow you to make certain selections or filters inside the graph. Where are these in Excel 2007? Can anybody help me? Thanks in advance! In Excel 2007 there's a PivotChart Filter Pane. It has dropdowns that you can use to filter the fields. Jelmer wrote: > In Excel 2003, If you made a graph of a pivot table you would have buttons > inside the graph that would allow you to make certain selections or filters > inside the graph. Where are these in Excel 2007? > > C...

Run Time Error 2501 "The report action was cancel"
hi I have a access database with some reports. All reports are working fine except one. When I click Priview or Print window I get the error "Report Action was canceled" and the error number is 2501. I try to ignore the error but report does not open. Any help in this regard. Here is my code. Private Sub Command15_Click() On Error GoTo Err_Command15_Click Dim stDocName As String stDocName = "Cash Voucher" DoCmd.OpenReport stDocName, acPreview ComeHere: Err_Command15_Click: If Err.Number = 2501 Then Resume ComeHere End If Any help in this regard ?? Thnx i...

Radio or Option button? Help Please
I'm having a problem, I'm copying a test from the web which has a radio/option button to use to choose the correct answer. My problem is when I paste it into my word document it has a black square around it. How can I erase the black square, but not the button? It looks ugly and will waste a ton of ink when I print this. Thanks in advance for all your help :) Can you replace it with the radio button in word? Just delete the one that comes over from the web. Ferrell "Rhonda" wrote: > I'm having a problem, I'm copying a test from the web ...

custom toolbar looses buttons when closed
Hi all, I've crossposted to three groups as I'm not sure of the best location. Apologies if this breaches protocol. my custom excel toolbar (office97) with macros linked to 3 buttons worked fine in Windows NT, but a recent enterprise wide upgrade to XP has resulted in the buttons on the toolbar dissapearing each time Excel is restarted. I understand this is because the C:\ drive is locked locked down to prevent changes. While I understand this will be rectified, IT changes are slow in our organisation. I also understand this prevents me changing the default file locations an...

Calling a SQL stored procedure from modified form button by VBA C
Hi All, I have a requirement to call the SQL stored procedure from GP modified form through button press and I do not want to use dextertiy development for this, I so can anyone show me how to do this through VBA code. Thanks in advance. -- Developer Dear, Use the following code: Dim conMain as New ADODB.Connection(ConnectionString) conMain.Execute("SQLCommand") Regards, -- Mohammad R. Daoud MCP, MCBMSP, MCTS, MCBMSS Software Development Manager +962 - 79 - 999 65 85 Great Package For Business Solutions daoudm@greatpbs.com http://www.greatpbs.com "Dexdev" ...

Update table with button
I have a query "New People Query" which is based on a few tables. Then I have a form "Alumni Form" which is based on the query. The form pulls up alumni records, so their ID number is on the form and each person has a record on the new People Query. I would like to be able to click a button and have it enter today's date and the alum's ID in a separate table "DeanMeet Tbl" which is linked by ID. The button is for each time I meet with someone, so I can click the button and it records that i met with them today. I might meet with people multiple times, whic...

Why don't these buttons show?
Hello all: Look: CThreadDlg *pThread; BOOL bThread; UINT MyThread( LPVOID pParam ) { int i=0; char str[10]; while(bThread) { itoa(i,str,10); pThread->GetDlgItem(IDC_EDIT1)->SetWindowText(str); i++; } return 0; } void CThreadDlg::OnButton1() { pThread=this; bThread=TRUE; AfxBeginThread(MyThread,NULL); } void CThreadDlg::OnButton2() { bThread=FALSE; } when this program run and I move the window,and then two bottons cann't show,who could tell me why and how to solve? Thanks. Lee Tow wrote: > Hello all: > Look: > CThreadDlg *pThread; > BOOL b...

Missing Toolbar button
I do not have the NEWS button on the GO dropdown. Nor do I have it under Toolbars/customize/commands/GO dropdown to enable adding it to the list. I had it once and put it in the GO dropdown but did not have server info to activate. When I next opened Outlook 2003, it was gone, not to be found in either place. Office help is no help here. Can anyone help? Thanks, Doug To get the News command back, go back to the Programs tab in Control Panel | Internet Options and change the default newsreader to Outlook Express. If OE prompts you to make it your default newsreader the next time...