Forms/subforms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Right now I have a database with the main form having a subform. I am
trying to clean up the main form because it has to much information and I
want to remove the subform and have it so there is a button to click to bring
up the information in what is now the subform. I can create the button and
get the macro to pull up the subform, but it's not pulling the information
tied to the correct record I am looking at in the main form. I tried adding
a where condition in the macro with something like
fieldxfrommainform=fieldyfromsubform but that didn't work. How do I tie the
2 together?

Thanks.
 
Basically you need something like

DoCmd.OpenForm "OriginalSubForm" , , , "fieldyfromsubform= " &
fieldxfrommainform

or if the matching fields are text

DoCmd.OpenForm "OriginalSubForm" , , , "fieldyfromsubform= '" &
fieldxfrommainform & "'"

If you use the button wizard it will generate the code for you.
 
I'm confused...do I use your Docmd code in the macro under the where
condition? I tried the button wizard for open form and run a macro and they
work just the same as when I manually did it. It opens the correct form, but
not for the correct record.
 
When you go through the wizard there is an option for

Form Operations / Open Form

You then pick on the form to open and then you get a choice of
"open the form and find specific data to display"
or
"open the form and show all the records"

If you select the first you then pick on the fields on the current form that
must match those on the form you are opening.

Can I suggest you paste the code you have?

Alternatively, if you are doing this in a macro, look at the nWind example
and a macro called
Customer Labels Dialog. About 20/21 rows down is a OpenReport with a where
condition.
 
or look at the Suppliers macro where there is a worked example for an open
form using the criteria

[SupplierID]=[Forms]![Suppliers]![SupplierID]
 
I don't get an option for that in the wizard, just an option to pick which
form to open. I am new to Access and am not a programmer so the code I have
is just fieldxfrommainform=fieldyfromsubform. This prompts me to enter a
value, so I enter the value from fieldx and it will pull up the correct
record. I don't want to have to enter the value though.

Thanks,
Lisa
 
Create a filter with the control name containing the data that you want to
use to bring up the new form and save it as a query.
Then, in a macro, OPENFORM and name your form you want to open. Then,
APPLYFILTER and name the filter saved as a query.
 
Back
Top