473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

before update cancel=true clears form

72 64KB
Hi,

I have a form with a subform, not linked.
In the Before Update of the subform I have:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.     On Error GoTo ErrorHandler
  3.  
  4.     Dim userAnswer As VbMsgBoxResult
  5.     userAnswer = MsgBox("Do you want to delete this Voucher?", vbQuestion + vbYesNo, "POS")
  6.  
  7.     Select Case userAnswer
  8.         Case vbYes
  9.             Me.Undo
  10.         Case vbNo
  11.             Cancel = True
  12.             Me.Parent.Tag = True   
  13.     End Select
  14.  
  15. exitSub:
  16.     Exit Sub
  17. ErrorHandler:
  18.     MsgBox "Error No: " & Err.Number & vbNewLine _
  19.          & "Error Details: " & Err.Description & vbNewLine _
  20.          & "Error in Sub: frmVouchers_NewVoucher\Form_BeforeUpdate"
  21.          Debug.Print Err.Number
  22.     Resume exitSub
  23.  
  24. End Sub
the only close button is in the Main form (the red X) and when pressed, if the subform is Dirty and the user chooses No, the Main form does not close but the subform goes to a new record instead of keeping the values entered.


Any Ideas why?


thanks
May 9 '20 #1
1 1624
NeoPa
32,556 Expert Mod 16PB
I'm not sure we can explain why the Main Form moves to a new record without any information related to the Record Source & what you're doing. However, the Main Form cannot close if a sub-form on it doesn't close. Cancel = True stopped the sub-form from closing so the Main Form is also stopped from closing.
May 9 '20 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Simon Holmes | last post by:
Hi, I am having trouble calling a UDF from a 'before update' trigger whereas I have no problems calling it from the 'after update' trigger. The trigger is as below : CREATE TRIGGER foo NO...
1
by: BLUE WATER | last post by:
Does anyone know how I can see a value in my form field text box ? I tried to add a text box, but the record source doesn't list the variable I want to see for each record. The variable is the...
1
by: Jason | last post by:
I have a main form with a sub form. All the fields in the subform are mandatory. I had some code on the main form Before Update Event to check if all the fields in the sub form have data. If not, I...
1
by: Rolan | last post by:
Having tried various permutations of Before Update and well for that matter, After Update, OnExit, OnEnter, etc. and also Locked controls, I'm still unable to obtain the intended results. There are...
1
by: gbb0330 | last post by:
Hi all i would like to thank Darryl, he helped me a lot now i have another problem LeBayNum is the primary key in relates to SeBayNum in tblSold relationship is one LeBayNUM to many...
0
by: samotek | last post by:
Io my main form i have a control called ChangePrice and on clkcing i set the focus to the control UnitPrice on the subform and enable the editing of the price. It cannot work because of the code...
5
by: wpellett | last post by:
I can not get the SQL compiler to rewrite my SQL UPDATE statement to include columns being SET in a Stored Procedure being called from a BEFORE UPDATE trigger. Example: create table...
2
by: ChrisHill | last post by:
I want to stop users from saving records within Access database without making the fields required in the table definition. Therefore I am putting edit code in the form's BeforeUpdate event. The...
22
by: DavidAustin | last post by:
I have probably a very simple query but cannot find the answer on google anywhere. Does the before update of a form fire before or after the OnClick event of a button? It makes sense to me that it...
2
by: Neruda | last post by:
Hi, hope u are all well. I only have a few textboxes to validate on a form; if I use the "before update" event on the form it seems that field validation on the table is triggered first and the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.