How to popupate a subform based on a field selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mnms
    New Member
    • May 2007
    • 8

    How to popupate a subform based on a field selection

    Hi,

    I'm trying to create an "overview" form. And I haven't been able to figure out how to get Access to do what I want yet.
    Basicly what I want, is to populate a subform based on a field selection. In other words, I have several fields like colour, shape, location etc. on my Main form. Now I want to add a subform to my unbound mainform, showing what I have in a table, depending on what is selected in the fields.
    So if I choose red, triangles from Warehouse 2 I'd like to show all the different products in my table that would match this criteria in my subform.

    But how do I go about it? Do I create a field on my mainform and change the value depending on what I select, and then somehow link my subform to that field or do I make it as some sort of VB code?
    I think the big issue is that I want to be able to switch what I show in my subform depending on what is selected on the mainform (I want to show a list of records, not just a single record), and I'm not entirely sure how to write such dynamic syntax... or where...

    I hope you can help,

    Br, MnMs
  • mnms
    New Member
    • May 2007
    • 8

    #2
    Gah, It seems every time I'm stuck at some problem and need some help I post here and voila - I come up with the solution myself - sorry about this. I found a solution to my problem. I just needed to set the recordsouce dynamicly. Fairly easy really. The example I found states:

    On event, add something like this:

    Me.Subformname. Form.RecordSour ce = "SELECT * FROM TableName;"
    Me.Subformname. Form.Requery

    or just give the name of a query.
    Me.Subformname. Form.RecordSour ce = "queryname"

    I did try and figure this out for a couple of days first though - so feel really silly now. I hope someone else can use this post...

    Comment

    • suzanne099
      New Member
      • Mar 2007
      • 7

      #3
      Thanks so much. I was trying to figure this out for days! Just wanted to let you know you really helped me so thank you for posting your solution!

      Comment

      Working...