Standard Access Procedure With VBA

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • Hi,


    I have built an Access Database and have used the wizard to help me create some of the Command Buttons as many of them move from record to record and open forms with specific filters applied to them to apply criteria to certain forms.


    I have also written some macro modules within the database to close down forms when new ones open to keep one form open at any one time.


    I would like to know whether or not it is possible to close down a form whilst applying a specific filter to the opening form and if so, how one goes about applying this section of VBA.


    Any help would be appreciated.


    Thanks In Advance
    Kieron

  • Re: Standard Access Procedure With VBA


    Hi Kieron:


    I am not fully aware of your need. What I understand is, you are opening a form from another form and applying some Filter on the newlyopening form and you want to close the previous form. To close a form you can use the following code


    Code
    DoCmd.Close acForm, "YourFormName", acSaveNo  'change this to acSaveYes if u want to save the form before closing.



    Regards


    Maqbool

  • Re: Standard Access Procedure With VBA


    Are you trying to open a form with a filter or save a form with the filter?


    Your original post appears to say that you want to close form A and open form B using the filter from form A.


    If this is so three things spring to mind in order of (personal) preference
    1. Do you need two separate forms or could they be placed as sub forms on a single form. When you click on a record in form A the records in Form B are automatically filtered.


    2. If you open the form using DoCmd.OpenForm then you can specify the records to view using the filter or where parameters.


    3. You can use the Openargs property to filter a form as it opens using an event procedure.


    As an aside, if you are actually opening and closing the same forms all of the time it may be quicker to hide and show the forms. This has some drawbacks, but it is often quicker.


    HTH,


    Alan.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!