Filter data from another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mapi
    New Member
    • Sep 2008
    • 2

    Filter data from another form

    I need help.

    I am new to MS Access and have been assign this project.

    I want to be able to filter data from a form that will be displayed on a subform.

    I don't know if this is possible but ideally i would like to double click on a field from Form A which will open a subform and display filtered data based on the data's site code that was double clicked.

    My database is for a budget tracker

    finance data will be entered for different sites. I would like an option for users to be able to click on a field in a form that will open another form so they can edit data which has been filtered for that site.
  • Echidna
    New Member
    • Jan 2008
    • 53

    #2
    Hi Mapi,

    this all depends on the fields and the data held within them.

    you can open a form selecting the Record you wish to alter:

    Code:
    docmd.OpenForm "<insert Formname>",<select windowmode>,<insert filter>
    the filter will be a field containing data consistent with both forms ie a Primary Key or other (preferrably) indexed field.

    ie "MyPK=" & me.<field you are double clicking>

    hope this helps


    Leon

    Comment

    • Mapi
      New Member
      • Sep 2008
      • 2

      #3
      I managed to do the first part which is open another form on double click but i can't seem to figure out the filter part. Can you please provide more info on the filter part.

      Thanks in advance

      Comment

      • Echidna
        New Member
        • Jan 2008
        • 53

        #4
        Hiya,

        I think i was a little ambiguous.

        does the subform contain the same recordsource (table / query) as the main form?
        if so, the filter (or where instruction) would be
        "[PK]=" & me.<PK>

        thus you are opening the form with the Primary Key of the record, this makes the margin for error a lot less than looking at data itself (unless you are certain it is unique accross the table(s)

        Hope this clears it up a little bit

        Leon

        Comment

        • jparkdo
          New Member
          • Oct 2008
          • 1

          #5
          I need to use a command button to open and filter a child of a child form. As a filter it needs to use the PK of the main form and the PK of the first child form to filter and open the child of the child form. Both PK's are referenced in the query the the 1st child form is based on.

          Basically, I just need to know if the filter "[PK]=" & me.<PK> can be modified to include two fields instead of one. Any ideas?

          Comment

          • Echidna
            New Member
            • Jan 2008
            • 53

            #6
            hi,

            you can filter a form on any number of criteria you choose as long as they exist within the recordsource, or within a Foreign Key Constraint.


            Code:
            "[PK]=" & me.(mainform)PK & "AND" & "[secondKey]=" & me.subfrm!secondKey

            hope this helps

            Leon

            Comment

            Working...