link pop up form to main form and filter by current record

J

Jon

I want to use a pop up, modal form instead of a subform and want similar
functionality to a subform. I have made the form, button to open etc all ok
but I am having difficulty getting the subform to only show the records
realting to the current record on the main form.

Any ideas?
 
R

Rick Brandt

Jon said:
I want to use a pop up, modal form instead of a subform and want
similar functionality to a subform. I have made the form, button to
open etc all ok but I am having difficulty getting the subform to
only show the records realting to the current record on the main form.

Any ideas?

The WHERE argument of the OpenForm method would typically be used to open
the Popup form pre-filtered to the records you want to see. One of the
choices provided by the CommandButton wizard will even do this for you.

What is another issue is that this will not give you subform type behavior
for NEW records. You will need to use code or other means to cause new
records to be automatically related to the main form record in the
background. One easy way is to set the default value property of the
controls bound to the related fields to something like...

=Forms!MainFormName!ControlName

Also, you will want to add a line to the code that opens the popup form that
saves the record in the main form prior to opening the popup form.
 
J

Jon

Thanks, I will try all this and get back to you.

I am not filtering anything, the pop up form is made from a table with a
one-to-many relationship with another, the main table/form in fact.
 
J

Jon

I appreciate it has been a while since this reply. I have followed the
instructions but the filter part does not work. I used the open form wizzard
and it asks me to select the two fields that will match. My main form is
called CONTACTS and the pop up fomr is called SITE DETAIL. They are based on
two related tables of the saem names. The tables are linked with a
one-to-many relationship, the many being on the side of SITE DETAILS. The
join is from the Contacts table field ID (primary key) to the SITE DETAILS
field Customer ID.

The WHERE condition in the SITE DETAIL form is "[Customer ID]=" & [ID]

BUT when the pop up opens from the main form all the records show and not
just the rcord(s) matching the current open record on the main form. Can you
help please?
=Forms!MainFormName!ControlName........ This bit works fine! When I make a new record on the pop up it automatically inserts the current main form ID in the Customer ID field.

Also, you will want to add a line to the code that opens the popup form that
saves the record in the main form prior to opening the popup form.

Exactly waht line of code shoule I enter where?

Thanks

John
 
J

Jon

I appreciate it has been a while since this reply. I have followed the
instructions but the filter part does not work. I used the open form wizzard
and it asks me to select the two fields that will match. My main form is
called CONTACTS and the pop up fomr is called SITE DETAIL. They are based on
two related tables of the saem names. The tables are linked with a
one-to-many relationship, the many being on the side of SITE DETAILS. The
join is from the Contacts table field ID (primary key) to the SITE DETAILS
field Customer ID.

The WHERE condition in the SITE DETAIL form is "[Customer ID]=" & [ID]

BUT when the pop up opens from the main form all the records show and not
just the rcord(s) matching the current open record on the main form. Can you
help please?
=Forms!MainFormName!ControlName........ This bit works fine! When I make a new record on the pop up it automatically inserts the current main form ID in the Customer ID field.

Also, you will want to add a line to the code that opens the popup form that
saves the record in the main form prior to opening the popup form.

Exactly waht line of code shoule I enter where?

Thanks
 
J

Jon

A bit of progress, this worked on the WHERE condition:
[Customer ID]=[Forms]![Contacts]![ID]

So I would just love to know where and what code I use to save the record in
the main form when i open the pop up?

Thanks

--
Regards, Jon


Jon said:
I appreciate it has been a while since this reply. I have followed the
instructions but the filter part does not work. I used the open form wizzard
and it asks me to select the two fields that will match. My main form is
called CONTACTS and the pop up fomr is called SITE DETAIL. They are based on
two related tables of the saem names. The tables are linked with a
one-to-many relationship, the many being on the side of SITE DETAILS. The
join is from the Contacts table field ID (primary key) to the SITE DETAILS
field Customer ID.

The WHERE condition in the SITE DETAIL form is "[Customer ID]=" & [ID]

BUT when the pop up opens from the main form all the records show and not
just the rcord(s) matching the current open record on the main form. Can you
help please?
=Forms!MainFormName!ControlName........ This bit works fine! When I make a new record on the pop up it automatically inserts the current main form ID in the Customer ID field.

Also, you will want to add a line to the code that opens the popup form that
saves the record in the main form prior to opening the popup form.

Exactly waht line of code shoule I enter where?

Thanks

--
Regards, Jon

--
Regards, Jon


Rick Brandt said:
The WHERE argument of the OpenForm method would typically be used to open
the Popup form pre-filtered to the records you want to see. One of the
choices provided by the CommandButton wizard will even do this for you.

What is another issue is that this will not give you subform type behavior
for NEW records. You will need to use code or other means to cause new
records to be automatically related to the main form record in the
background. One easy way is to set the default value property of the
controls bound to the related fields to something like...

=Forms!MainFormName!ControlName

Also, you will want to add a line to the code that opens the popup form that
saves the record in the main form prior to opening the popup form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top