Switch between forms

Dowsey1977

Board Regular
Joined
Apr 6, 2004
Messages
185
Hi,

I have a form that records a load of people's person data, and a form that contains other information about that person.

What I want to be able to do is press a button when looking at the person data form and it brings up the other information form only showing the record for that person.

Any ideas?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Make a button that will open the other form.

When clicked, this button will do the docmd.openform action. For the form that's opened, adjust the form's recordsource so it has the field in it by which it needs to be filtered (form properties|data|recordsource). Right click in the criteria for this field, select build, and 'browse' to the control from the originating form that contains the value by which you want the second form to be filtered. That should do it.
 
Upvote 0
I want to be able to open the 2nd form normally as well as from the person data form, and view all the records. Will I need to have 2 copies of the same form?
 
Upvote 0
Then there's two options I know of.

1.
Make a copy of the second form. One copy will serve to access all records. The other copy is a 'review' form, that is filtered on the selection made in the first form.

2.
Set the recordsource of the second form programmaticaly. One cool way to do this is to something to the effect of:

Execute when the button to open the second form is clicked:

Code:
strSQL = form2.recordsource
form2.recordsource = replace(strSQL,";"," WHERE ID=" yourIDcontrol & ";")

Basically, just adding the WHERE condition to the end of the SQL that already exists for the form.

Actually, a third method would be to use the bookmark method, but I don't like that way. You can drop a combo on this second form and use the wizard (tell the wizard you want the form to go to the record selected in a control) to get your code.

I prefer two forms, usually the form to review the person specified in form1 is a little different than the form that allows for access to all records.
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,250
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top