简体   繁体   中英

MS Access Filter Child Table by Record Chose on Form

I'm trying to create a simple 2 table database - table 1 holds ClientInfo and table 2 has ClientVisits - Relationship is on ClientInfo.ID->ClientVisits.ClientID. Then I have a form created thus for viewing the ClientInfo plus a child(sub?)table which SHOULD show all the records from ClientVisits where my Form ClientID = ClientVisits.ClientID.

Here is my form

Here is the child table with fields shown

Relationships

So I already have one record in ClientVisits for the currently chosen ClientID form record. But it doesn't show in my Table.ClientVisits. Other than the relationship I don't have any other link between the ClientID and the ClientVisits.ClientID field.

If I need to post further info please let me know, trying to describe this as well as I can - sorry if it's not making sense. Thanks.

You have to link both tables in your form.

In my example, main data of my form is a table called CLIENTES , where it shows all the information about a cliente. It would be exactly the same as your table ClientDetails . In this table, primary key is a field called DNI (it would be the equivalent of your ID field)

I got a second table called CONSULTAS MÉDICAS . This table is just a list of how many times this client comes to see us. It would be the same as your secondary table CLIENT VISITS. In this table, I got a field called PACIENTE , linked to my table CLIENTES . Let me show you.

在此处输入图片说明

Ok, now my form is done based on the data of my table CLIENTES , but I got a subform control, where I have linked the table CONSULTAS MÉDICAS

在此处输入图片说明

To make this work is pretty easy. Not filters or queries. Just linked child and master fields. To do this, you have to select properties of your subform control, and then go to DATA TAB

在此处输入图片说明

Just choose as main field your ID field from table CLIENT DETAILS and link it to child field CLIENT ID from table CLIENT VISITS

That should work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM