Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Navigation tab, undorecord on exit event

  1. #1
    Board Regular
    Join Date
    Jan 2015
    Posts
    850
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Navigation tab, undorecord on exit event

    Hi,

    I have a form to add new employees (LastName and FirstName with new unseen EmployeeID) to Employees table. I have a save (it saves the record and goto NewRecord) and cancel button
    Code:
    RunMenuCommand
                 Command UndoRecord
    , which basically delete what is typed in both fields of the form.

    Both work as expected.

    My problem is since I put this form in a navigation form, if I type something and leave the tab, it will save the record and I would like to avoid that.

    I thought "Easy, I will apply the RunMenuCommand UndoRecord as above but on exit event"
    Unfortunately I recieve an error message that maybe database is in read only or maybe the undoRecord is not supported by this version of Access (which make no sense since the cancel button works).
    Strangely enough, the message comes when I come on the tab, not when I leave it.

    Should I add a condition to the exit event that if there are caracters in one of the fiels, undo record or is it the RunMenuCommand that can not be associated to a tab? Any suggestion?
    Last edited by Kamolga; Oct 24th, 2018 at 06:44 AM.

  2. #2
    Board Regular
    Join Date
    Jun 2015
    Location
    Ontario, Canada
    Posts
    1,618
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Navigation tab, undorecord on exit event

    I've never used a nav form that I didn't build myself and after reading about their issues, probably never will. Thus I can only make observations based on that, and since you've had 90 views with no replies, I'll share what little I know about them.

    A nav form only 'holds' one form at a time. When you choose a new tab, you close the form that's currently in view. Closing a form is one of the actions that commits a record that doesn't violate any validation rules, so you cannot simply undo, at least not without intervention.

    To work around this, you'd have to put validation code in the form Unload event and cancel the unload if validation fails. Your close button Click event could simply be
    DoCmd.Close
    which would call the Unload event automatically because Unload occurs before Close event. If validation fails, you Cancel the unload event. However, in the click event, you'll have to handle error 2501 ("the close event was canceled") so as to not present that to the user. The reason for this approach would be that the Unload event can be canceled, but the Close event cannot.

    BTW, it has oft been written that RunCommand should be used rarely, although I can't recall why. It's one of those things that if you never use it, you forget why not.
    Last edited by Micron; Oct 28th, 2018 at 01:14 AM. Reason: clarification and correction
    Tips for posting problems:
    1) "doesn't work" doesn't help. Post error message text/numbers and/or state what's happening.
    2) if posting code or sql, use code tags; specify on which code line errors occur, if applicable
    3) try to be specific; assume we know nothing about your issue - because we don't!

    Make all suggested changes in copies of your database or to its objects.

    "1 out of 1010 people understand binary. The other 1001 don't."

  3. #3
    Board Regular
    Join Date
    Jun 2015
    Location
    Ontario, Canada
    Posts
    1,618
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Navigation tab, undorecord on exit event

    I don't understand the question. As I mentioned, if we're talking about a navigation form, the form is loaded into the nav form when you click on the tab for the form you want to see. When you select a different tab, the current form is closed and the next chosen one opens. Whatever you've designed to have happen when those forms open or close will happen. If you want to have something happen before a form is chosen, you'll have to provide for that. If you don't want a form to be able to be opened before that point, you'll need a marker/flag/condition that tells Access not to allow the form to be opened. It seems your issue is expanding quite a bit from your originally posted question?

  4. #4
    Board Regular
    Join Date
    Jan 2015
    Posts
    850
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Navigation tab, undorecord on exit event

    Quote Originally Posted by Micron View Post
    I've never used a nav form that I didn't build myself and after reading about their issues, probably never will. Thus I can only make observations based on that, and since you've had 90 views with no replies, I'll share what little I know about them.
    Thank you for taking the time and sorry for late answer, I left the project on hold for some time. I opted for my own starting form as it gave me more control and since I am not sure what I will add in 1 month. I don't formally ban navigation form but will avoid it nearly all the time for that reason.
    Last edited by Kamolga; Nov 9th, 2018 at 04:26 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •