+ Reply to Thread
Results 1 to 5 of 5

Access subform VBA set filter settings by main form

  1. #1
    Registered User
    Join Date
    02-20-2013
    Location
    Oregon
    MS-Off Ver
    Excel 2010
    Posts
    18

    Access subform VBA set filter settings by main form

    Hello Everyone, thanks in advance for the help!

    I have an Access database that uses forms as a 'front-end' data entry apparatus; more precisely subforms to collect these data within the form. There are several departments within our company and each department has their own form to enter data. To complicate things, I have subforms within each form. Each subform collects data for a different table.

    For example, I have a 'Purchasing' department form, and they use the 'Budget' subform to enter their budget information. They also have a 'Employee' subform within their form, and a 'Materials' subform.

    What I would like to do is create a VBA code that will automatically filter the subforms based on the form that is opened. For example when Purchasing opens their form, Budget, Employee, and Materials subforms will automatically be filtered by 'Department'.

    Here is the code I am currently struggling with. I have it placed on the Property Sheet/Event Tab/On Open category:

    HTML Code: 
    So for each subform, I want to implant this code in the hopes that I can automatically filter every subform within the respective forms for each department. Same subform, but different forms. I'm hoping the VBA code can be used to automatically filter each subform based on the filter that is opened by the department.

    Hope I have explained my issue with sufficient detail

    Much Thanks,
    -Polar

  2. #2
    Registered User
    Join Date
    02-20-2013
    Location
    Oregon
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Access subform VBA set filter settings by main form

    Well I have been successful in getting the code to produce an automatic filter when the form is open. However when I try to re-open the form again (after closing it), the following error is produced:

    Runtime Error '2475' You entered an expression that requires a form to be the active window.

    Here is the clumsy code I am currently struggling with:

    HTML Code: 
    Any help would be greatly appreciated

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Access subform VBA set filter settings by main form

    One of the common ways to achieve this is to have the department name tied to the login id.

    As each user will have a login id , you need to add additional field in your user master to add the department name.

    Use this field to apply a filter, through out the users session.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Registered User
    Join Date
    02-20-2013
    Location
    Oregon
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Access subform VBA set filter settings by main form

    Hmmmmm...very interesting idea...I will put some thought into this!

    Thank you for the response

    I still would like a solution to my code error

  5. #5
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Access subform VBA set filter settings by main form

    Just before this line

    Please Login or Register  to view this content.
    put this line to see what you are getting :

    Please Login or Register  to view this content.
    if you get the form's name, then instead of using fend directly refer to the Screen.Activedform .

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Form with Subform and combo boxes to filter
    By CRIMEDOG in forum Access Tables & Databases
    Replies: 0
    Last Post: 07-18-2013, 05:46 PM
  2. hide subform when open them main form
    By pedjvak in forum Access Tables & Databases
    Replies: 4
    Last Post: 04-09-2013, 08:21 PM
  3. Main Form Multiple Combo Boxes Control Subform textboxes
    By jvbeats in forum Access Tables & Databases
    Replies: 0
    Last Post: 02-01-2013, 01:36 PM
  4. [SOLVED] Access Database Search filter for subform based on query
    By carden2 in forum Access Tables & Databases
    Replies: 1
    Last Post: 10-07-2012, 11:16 PM
  5. Replies: 0
    Last Post: 04-08-2009, 06:42 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1