Results 1 to 5 of 5
  1. #1
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    144

    Form's Undo method doesn't work properly.

    Hello to all!
    I have set a BeforeUpdate event to my form with a popup message box. If the user clicks no to the msgbox, the procedure runs as - Cancel = True Me.Undo. But if I want to navigate to the next record and click No to the msgbox the procedure does not seem to undo the form completely. Because it shows the same message over and over again and does not move. I have to press Escape key with my hand before I can do the navigation. But if I click the close form button, then it seems to be able to undo the form and let me close the form. I tried Docmd.Runcommand accmdUndo. Also tried to use sendkeys "{ESCAPE}" but it's all the same. In my form I have both bound and unbound comboboxes, textbox and checkbox. On the OnGotFocus event of one of my comboboxes I have applied a selected method so that when the focus is on, it automatically select the last item of the rowsource of combobox. But on the BeforeUpdate event I have moved the focus to elsewhere if update were declined. That line of code was placed before the line of Cancel = True.
    There is one more problem. The combobox in question shows blank as I move through the records. However it is a bound combobox. It's rowsource is a query. It's filter property is Yes.
    The form also has a tabcontrol which I use to house some queries in order to ease my data entry.
    I have another button on the form which aloso has a Me.Undo method. But that seems to work perfectly.

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,742
    Try doing it the other way around.

    Me.Undo
    Cancel = True

    However all you really want is Me.Undo

    Cancel = True will prevent the form moving from the record at all, as you are cancelling the save of the record.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,781
    Are you trying to make a record move (e.g. by button click), which then fires the BeforeUpdate event, then canceling the update and expecting to move to the next record? That's my interpretation. If so, you probably also need this somewhere (probably the BeforeUpdate event, perhaps after the cancel)
    If Not Me.NewRecord Then DoCmd.GoToRecord , , acNext
    The combobox in question shows blank as I move through the records. However it is a bound combobox. It's rowsource is a query. It's filter property is Yes.
    Then there is nothing in its field in those records, or you've applied a filter to it. The rowsource of a combo does not govern what is shown in the combo - that property applies to the combo list rows. The combo can show nothing (because it's bound as as I stated, the field has no value) and in fact you can often add values to the list that are not already there by way of the combo itself.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  4. #4
    bubai is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Nov 2014
    Location
    Dhaka
    Posts
    144
    Quote Originally Posted by Micron View Post
    Are you trying to make a record move (e.g. by button click), which then fires the BeforeUpdate event, then canceling the update and expecting to move to the next record?
    My goal is not to move from record to record here, but to find out what is causing this anomaly. As I have already mentioned that I have another button on the form which also has a Me.Undo method. But that can handle the Undo perfectly. But for this one I have to manuallypress the Escape key to clear the form and then it lets me move. Also if I try to go to design view, it behaves the same.

    Then there is nothing in its field in those records, or you've applied a filter to it.
    If by Filter you mean criteria, then Yes, I have where clause in the query of the comboboxe's rowsource which shows as criteria in the query grid. And if you mean Filter on load property, then also yes, it has filter. But even if clear the filter the combobbox does not show field value which is existent and which it should have shown.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,781
    But for this one I have to manuallypress the Escape key to clear the form
    That is the manual equivalent of Undo. Since you cancel the event first, you can't then Undo, so reverse the order of those statements as noted and you should be good.

    Filter on load doesn't apply a filter that isn't there, and the where clause in a query for the combo rowsource isn't a filter. I'm saying that when comparing one record to another, if a combo doesn't have a value in it, then that field in that record has no value. Let's forget the filter thing because in retrospect, if you applied a filter to a form you wouldn't even get certain records. It's not like you can filter out just one field and still see the rest of the fields in those records. I must have been experiencing caffeine impairment.

    If you can't get the BeforeUpdate canceled properly, copy you db, compact and zip the copy and post it here.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update Query Doesn't work from my Form
    By Wagon in forum Forms
    Replies: 3
    Last Post: 06-13-2016, 06:02 AM
  2. Replies: 5
    Last Post: 06-09-2015, 08:45 PM
  3. Append doesn't work properly
    By fluppe in forum Access
    Replies: 3
    Last Post: 10-17-2014, 12:50 AM
  4. Replies: 10
    Last Post: 11-20-2013, 04:18 PM
  5. Combo box doesn't work properly
    By joe1987 in forum Forms
    Replies: 9
    Last Post: 11-10-2011, 04:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums