Cancel/BeforeUpdate Event Procedure

I have a main form Containers with a subform ContainerSubstances.  The latter 
has a combo box showing the substances in the Substances table.  If the 
desired substance is not in the combo, the user may bring up the Substances 
form in Add and Dialog mode.  The user can press Save or Cancel from the 
latter form, and both work as designed.

If Save is pressed, the combo box on the original subform is requeried to 
include the new value, and then the new value is selected by the code, and 
the Substances form closes, and the user returns to the Containers form, with 
focus set in the subform.  All of this works.

The Containers form has its own set of Save/Cancel buttons.  If its Cancel 
button is pressed, any changes made on the Main form are undone, but not the 
subform, including the change to the combo box.

Private Sub cmdCancel_Click()
On Error GoTo Err_Handler
   
    If Me.Dirty = True Then
        Me.sbfContainerSubstances.Form.Undo
        Me.Undo
    End If
        
    DoCmd.Close acForm, Me.Name

Err_Exit:
    Exit Sub

Err_Handler:
    Select Case Err.Number
        Case Else
            MsgBox Err.Number & vbCrLf & Err.Description
            Resume Err_Exit
    End Select

End Sub

Does anyone have a suggestion?  Do I need to copy the state of the subform 
to an array temporarily, and reset it?

Thank you.

Best regards,
Sprinks
0
Utf
4/27/2010 2:19:01 AM
access.forms 6864 articles. 2 followers. Follow

1 Replies
1011 Views

Similar Articles

[PageSpeed] 10

The problem is that once you move the cursor out of the subform to click the 
save button on the main form, that makes access trigger the subform to save 
the record.
Usually this is what we all want in our apps.

Same type of thing happens when you move the cursor out of the main form 
into the subform, access saves the main form.

I have very occasionally put an undo button on the subform.
You can instead write code to delete all the related subform records for 
that main form record (I think I have only ever done this once).
This code would run when you click the undo button on the main form.
Then you would requery the subform.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Sprinks" <Sprinks@discussions.microsoft.com> wrote in message 
news:97FBDC32-378D-4EEA-A79D-1979F7A7EA46@microsoft.com...
>I have a main form Containers with a subform ContainerSubstances.  The 
>latter
> has a combo box showing the substances in the Substances table.  If the
> desired substance is not in the combo, the user may bring up the 
> Substances
> form in Add and Dialog mode.  The user can press Save or Cancel from the
> latter form, and both work as designed.
>
> If Save is pressed, the combo box on the original subform is requeried to
> include the new value, and then the new value is selected by the code, and
> the Substances form closes, and the user returns to the Containers form, 
> with
> focus set in the subform.  All of this works.
>
> The Containers form has its own set of Save/Cancel buttons.  If its Cancel
> button is pressed, any changes made on the Main form are undone, but not 
> the
> subform, including the change to the combo box.
>
> Private Sub cmdCancel_Click()
> On Error GoTo Err_Handler
>
>    If Me.Dirty = True Then
>        Me.sbfContainerSubstances.Form.Undo
>        Me.Undo
>    End If
>
>    DoCmd.Close acForm, Me.Name
>
> Err_Exit:
>    Exit Sub
>
> Err_Handler:
>    Select Case Err.Number
>        Case Else
>            MsgBox Err.Number & vbCrLf & Err.Description
>            Resume Err_Exit
>    End Select
>
> End Sub
>
> Does anyone have a suggestion?  Do I need to copy the state of the subform
> to an array temporarily, and reset it?
>
> Thank you.
>
> Best regards,
> Sprinks 


0
Jeanette
4/27/2010 5:33:07 AM
Reply:

Similar Artilces:

Was Myst Technology 2007 ORS add-in cancelled?
An Element K course book calls for the Myst Technology ORS "FindWhatORS" service to be added to the Research Task Pane. The add-in cannot be found. Was this service cancelled? ...

Identity Switch Cancelled
Everytime I start Outlook I get an error popup that says. "Identity Switch Canceled. The current identity could not be changed because one of the applications was unable to switch. Close any open dialog boxes in other applications before trying again." I found this Knowledge Base Article but i cant figure out what they are wanting me to do??? Please Help here is KB Microsoft Knowledge Base Article - 224463 Ross, this newsgroup is for support of Outlook 97/98/2000/2002/2003(beta) from the Office suite of products. Outlook Express is actually a separate program despite the si...

KDC event log error 11
I have a client that has installed MS CRM 1.2 on SBS 2003 PE. It looks like a bad install. It appears they may have even installed it twice because there are 2 x ‘CompanyX CRM version 1.2’ websites in IIS (one installed over the top of companyweb), and their RRW doesn’t work. They didn’t set up a new user to run the CRM service - they installed as Administrator and CRM uses that. They are getting KDC error's in the event log (event ID 11) and have complained about authentication errors. There are several different SPN's listed in the event log as being duplicated. The errors look ...

How do I cancel meetings I organized but am not attending?
I organized recurring meetings with co-workers for the rest of the year. They needed to be cancelled. I successfully cancelled them from my calendar, but not the other attendees' calendars. Now I'm stuck! ...

Event ID: 1000 --- faulting application store.exe
Scenario Exch 2003 Enterprise on Win 2k3 Standard, both native mode Sunbelt's iHateSpam Server Editio Panda Antivirus Exchange Secur Recently, we've had situations where the information store would just stop with the above error. I also get a 348: "A message could not be virus scanned..." I finally had to set the store to restart itself after a failure. But it's a hassle with all the calls from users I expect I will have to talk to Panda support about this, but I just wondered if anybody in the group had any advice before I get started on that path.. Thanks Bob Has...

Cancel Read Only
Please tell me how to delete read only in msexcel. I need read/write. "Kutty" wrote: > Please tell me how to delete read only in msexcel. I need read/write. Go to the Review tab and unprotect the worksheet. ...

Not having to wait for routine to finsh / run three events at the same time
I developed a simple app, it goes out to an access db and populates a list box and pings as server. Pretty much how can I do both events at the same time without haveing to wait for one to complete before moving on to the next one. It acts like an application monitor where I ping the servers every 15mins and see if they are up, they are totally seperate Public routines, sound simpel but it is not. I just want to ping all three severs and get the ping times. I have everything coded it is just the waiting that has me stuck! Thanks Your problem is a typical example where a backgroundwork...

Cancel Button not working
I have a message pop up when a command button is pressed to run a report. The problem is the cancel button is not cancelling the action. It still runs the report like you pressed ok. What am I missing? Response = MsgBox("Approximate wait time is 5 minutes." _ & Chr(10) & Chr(13) & _ "Push OK to continue,Cancel to Quit", 1) -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201002/1 Perhaps you need to go back and look at Access Help for MsgBox! Your posted ...

Cancelling Links
Hello, I am having trouble removing links between spreadsheets, when they are no longer required. Can someone please help. Thanks Susie Try Bill Manville's excellent "FindLink" utility It's available at Stephen Bullen's page: http://www.bmsltd.ie/MVP/Default.htm -- Rgds Max xl 97 --- Please respond in thread xdemechanik <at>yahoo<dot>com ---- "susie" <anonymous@discussions.microsoft.com> wrote in message news:2b1d01c49d83$0f33dbf0$a401280a@phx.gbl... > Hello, > > I am having trouble removing links between spreadsheets, > when t...

Event time off by an hour
I know this issue has been brought up before but some of our users are still encoutering it. When a meeting is created and others invited, the time they get when they accept the request is an hour earlier than the original time. We have set the outlook time to match the system time and time zone and day light savings is enabled both in the control panel and the Outlook calendar time. We also made sure the system time matches the system bios time. All users are in the same time zone. Is there anything else I need to be looking for? This is a very serious situation as we have a lot ...

cancel
Control: cancel <Oqv$wT1#KHA.3952@TK2MSFTNGP02.phx.gbl> Make sure to all you medication. Do not let Chinese worker steal your fast food job "Stan Starinski" <China@stealsUSJobsPatentsSoftwareMusicVideo> wrote in message news:#IQEws1#KHA.3840@TK2MSFTNGP02.phx.gbl... > Control: cancel <Oqv$wT1#KHA.3952@TK2MSFTNGP02.phx.gbl> ...

sqlserveragent warning in event log
Can anyone shed some light on this warning message in the event log? SQL Server Scheduled Job 'Start_Incremental on Ross_Industries_MSCRM.ftcat_documentindex.[7.5]' (0x8D29E78EB4C5BA4CA196ACEBD99AD2A1) - Status: Failed - Invoked on: 2007-04-08 20:15:00 - Message: The job failed. The Job was invoked by Schedule 9 (Indexed Document Title Schedule). The last step to run was step 1 (Full-Text Indexing). Thanks, -Rick M. ...

Can you make a timeline for a day in minutes, w/overlapping event
I'm trying to chart the overlapping times of someones activities in a day, so I can see how often they are overlapping and it needs to be to the minute. Any Ideas? Dan E Take a look at this post, it shows how to make a room schedule for a day. The downloadable workbook should get you started. http://processtrends.com/pg_oper_room_sched.htm Kelly http://processtrends.com "Dan E" <Dan E@discussions.microsoft.com> wrote in message news:E9B27C66-0418-4631-B22D-B6D44F7C205D@microsoft.com... > I'm trying to chart the overlapping times of someones activities in...

Event Sinks and Printing
I have a somewhat unique issue, I think. I want to be able to take all mail received to a specific mailbox, print it, and delete the message after printing. Does anyone have a sample script I can use to do this? Also, the users would be coming through a terminal session to execute the printing. When they hit print, we are going to pass it through our print servers which will strip off the header information and email it to their mailboxes. Once it gets there, it should automatically print to their printer. Can I tie this event to their particular terminal session and the printer t...

Attribute Event
Can anyone share what is wrong with the following event script? MethodOfService is a drop-down field, and I'm wanting to populate the visual values into Subject. crmForm.all.subject.DataValue = switch(crmForm.all.new_methodofservice.DataValue) {case 1: "Remote Access" break; case 2: "Web Session w/Client" break; case 4: "Off-Site" break; case 5: "On-Site" break; case 6: "EMail Only" break; case 3: "Phone Call Only" break; default: "Other"}; Hi Cindy, the switch statement does not return a value thus the assignmen...

how do i cancel outlook as my e-mail?
hello -- while looking for a message i sent thru "word," somehow i managed to make "outlook" my e-mail inbox. i want to go back to having my comcast.net inbox for my e-mail, and not have anything go thru outlook. help! i know everyone in the world apparently loves outlook, but i hate it! thanks very much for all suggestions. If you want to get your Comcast e-mail via the web interface, just go to the Comcast e-mail webpage and continue to use Comcast's web mail program. Outlook is a desktop e-mail program. You don’t have to use it if you don’t ...

Cancel Changes
I am about to upgrade to GP 10 and I am displeased to find that there is not a "Cancel" or "Discard Changes" option when backing out of Sales Transaction Entry after opening an existing open document. I understand the process but has a temp table not been implemented so that changes do not actually hit the database until confirmed by the user? AllenMc, There is a complete explanation on why the system is designed this way on David Musgrave's Blog, "Developing for Dynamics GP", at http://blogs.msdn.com/developingfordynamicsgp/archive/2008/08/18/why-can-...

event log entry regarding time service
This is not so much a PowerShell question, but I'd like to know what to do to fix my time service on XP after discovering this event log entry by using PowerShell Get-EventLog -Logname system -Source w32time | Select-Object TimeGenerated, Message | Sort-Object TimeGenerated | Select-Object -last 1 | format-Table -wrap -autosize TimeGenerated Message ------------- ------- 4/11/2010 4:20:01 AM The time service has not been able to synchronize the syst em time for 49152 seconds because none of the...

Event 1022
Hey all, I have an E2K3 cluster running on W2K3 in active / passive configuration. When I fail my cluster over for the next 30 or so minutes I get a rash of 1022 erros for a bunch of different users. In E2K this usually had something to do with possible bad disks but it doesn't appear to be the same error in 2K3. I haven't found much good reading on the topic but my disks are fine and I have a ton of errors and my cluster isn't failing over as clean or as fast as it should as a result. Any ideas? I'm also cross posting in the cluster group. Thanks, Dan Event 1022...

event & computer time zones do not match.
Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel Email Client: pop I'm in the Eastern Standard Time Zone and we &quot;sprung forward&quot; on March 14. That seems to have wreaked havoc on my calendar for about 3 weeks until when it thinks I should spring forward. Times switched automatically and in order to correct them, I had to go in and manually input the wrong time so it would be correct in the calendar view. The message I got was &quot;event and computer time zones do not match. In calendar views, the event is adjusted to display correctly.&a...

Cancel and clear.
how do i cancel this mail and clear all existing items. Jim Matson. ? Please explain in more detail what you are trying to do. Gary VanderMolen, Microsoft MVP (Mail) "jim matson" wrote in message news:O4j9FjaDLHA.2052@TK2MSFTNGP06.phx.gbl... how do i cancel this mail and clear all existing items. Jim Matson. Go to the outbox and delete the messages. steve "jim matson" <jimsan@slingshot.co.nz> wrote in message = news:O4j9FjaDLHA.2052@TK2MSFTNGP06.phx.gbl... > how do i cancel this mail and clear all existing items. > Jim Matson. ...

Handling the WorkbookAfterSave Event in VBA
I can handle the Excel WorkbookAfterSave event in VB 2010 as explained at http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.appevents_event.workbookaftersave(office.14).aspx. I can also handle built-in events of the Excel application in VBA as described at http://msdn.microsoft.com/en-us/library/aa140934(v=office.10).aspx. However, I cannot figure out how to handle the WorkbookAfterSave event in VBA. If I use a statement such as: Private WithEvents ExcelApp as Application a number of application events are available, but WorkbookAfterSave isn't on...

quantity canceled
When cancelling a quantity on a Purchase Order, would like a seperate field to track the reason why the quantity was cancelled. How about using the line item comment for this? -- Victoria Yudin Microsoft MVP - Great Plains "jhauge" <jhauge@discussions.microsoft.com> wrote in message news:9A117886-C5D2-47E4-82FA-D1201F2D7E5D@microsoft.com... > When cancelling a quantity on a Purchase Order, would like a seperate > field > to track the reason why the quantity was cancelled. ...

Event Script for Case Attribute
Can anyone share what is wrong with the following event script? MethodOfService is a drop-down field, and I'm wanting to populate the visual values into Subject. crmForm.all.subject.DataValue = switch(crmForm.all.new_methodofservice.DataValue) {case 1: "Remote Access" break; case 2: "Web Session w/Client" break; case 4: "Off-Site" break; case 5: "On-Site" break; case 6: "EMail Only" break; case 3: "Phone Call Only" break; default: "Other"}; switch(crmForm.all.new_methodofservice.DataValue) { case 1: crmForm.all.sub...

Access Iframe object from an Event
Hello, Is it possible to access and change iframe object value from an onChange Event in CRM. If yes what is the syntax to do it ? Currently I am using this syntax : var test = crmForm.all.IFRAME_myIframe.Document.formId.objectId.value; alert(test); And I receive an error saying that 'Permission Denied' when i change my field... -- Clo here's the code to set a link for your iframe. var link =3D "www.yahoo.com"; crmForm.all.IFRAME_[YOUR IFRAME NAME].src =3D link; to access your iframe object. var iframe - crmForm.all.iFRAME_[YOUR IFRAME NAME]; Hope this helps. ...