Share via

Programming with Navigation form - Navigation buttons

Anonymous
2011-12-12T11:21:54+00:00

Hi!

First of all, I am not a native English speaker so my apologies for my grammar and vocabulary. Also I am pretty new to Access so again my apologies if the terms I'm using are not too accurate  :S

The issue I'm facing is related to Access 2010.

I have a Navigation form with to 2 "subforms" embedded (I call them "subforms" because I am assuming that they are subforms with respect to the main Navigation form, however they are really main forms): "Leads" and "Colegios". There are 2 navigation buttons in the Navigation form that open each one of them.

In each subform, I have created a button to close it (the "X" button is disabled). Attached to this button there is some code to control whether there was a record being edited or not, in case a record was being edited a Msgbox is displayed asking whether to go on and close the form or to return to the record and keep on editing it.

If I open one of these subforms by itself, this "close" button works fine, but when I open them from within the Navigation form it is useless for 2 reasons:

  1. If I am currently in the Lead subform and I press the "Colegios" navigation button, the "colegios" subform replaces the "leads" one without controlling anything about records that were being edited.
  2. If I press the "close" button I inserted, it closes not only the form the button is in but also the navigation form and I can't go on from there and I have to close and open Access again. This is because I have hidden the navigation pannel and the ribbon.

Is there any way I can apply this code to control the edition of a record to a Navigation button to prevent a form from exiting it if a record is currently being edited?

I hope I have explained myself properly.

Thanks!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2011-12-13T19:34:57+00:00

    So... it doesn't sound too optimistic...

    Yeah, it looks like I will end up building my own homemade navigation form. I was trying to use the "out of the box" one since it is quite easy and quick to use and implement.

    I will try to research a little bit more in order to find out if there is a way to do it using the Navigation form, in case I can't I wouldn't say I will not ask for some help  ;-)

    I have created these "close" buttons because every time I save a record, I execute a bunch of tasks (updating some tables, clearing out some fields...) and I do not want the users to leave the current record without doing it. Maybe I could attach all this code to the lost focus event or something like that... I will think about it.

    Thanks for your help!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-12-13T19:27:00+00:00

    Thanks for your answer!

    I have looking into these alternatives but I can't see how can I stop the form from closing, the only event that I have seen that has a variable to stop it is On Unload where you can set the variable "Cancel" to True.

    Unfortunately, even the Onload event didn't work (or I did not know how to make it work the way I want)

    How can I stop leaving the form I am in using the events you mentioned (lost focus, etc.)?

    Thanks

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-12-12T13:31:05+00:00

    No, you can not do that.  You have corretly deduced what the problem is - you can not "close" a subform.   The form object that is displayed in a subform control is automatically terminated (closed) when you select a different "form" in the navigation form.  The navigation form is not much more than an unbound main form with a single subform control and selecting a navigation form tab essentially just changes the subform control's SourceObject property.

    The only reason I can see why MS added the navigation form is that it might be useful in a web form.  In a normal Access application, as I described above, it is a simply some command buttons and a little code to do the same things a navigation form can do.

    I think the way to get the effects you describe is to create your own main form with separate subform controls, one on top of another.  Then use command bittons to make one subform control visible and the others invisible.  Think about it and post back if you decide to go it this way and need help doing it.

    You have not explained why you think you need these "X" buttons to "close" a subform and confirm saving the edited record.  Is it because your users often enter a record and then decide they did not not really mean it?  From my point of view, this is a very unusual situation and users can just hit the Esc key twice to do the same thing.  Anyway, even if an unintended record is saved, why not just let users delete the record?

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,810 Reputation points Volunteer Moderator
    2011-12-12T13:25:56+00:00

    First, you explained yourself perfectly. 

    What I would do is use the Lost Focus, On Deactivate or On Exit events to control this. Basically, you don't want the user to leave the form until the record is properly processed. So you can use those events to detect if the user is trying to move from the current form.

    Was this answer helpful?

    0 comments No comments