form-subform

  • Thread starter Jean-Paul De Winter
  • Start date
J

Jean-Paul De Winter

Hi,
I have a form with a subform
The main form has a selectiongroup with 6 items
the subform should be based upon the choise I made in this selectiongroup


The subgroups name is kader25
the subform=oefening

as code I wrote

If Me!Kader25 = 1 Then
Me!SubForm.Form!Oefening.Filter = "PSY"
End If
which returns the object subform isn't known...

What is the correct syntax?
Thanks
JP
 
M

Marshall Barton

Jean-Paul De Winter said:
I have a form with a subform
The main form has a selectiongroup with 6 items
the subform should be based upon the choise I made in this selectiongroup


The subgroups name is kader25
the subform=oefening

as code I wrote

If Me!Kader25 = 1 Then
Me!SubForm.Form!Oefening.Filter = "PSY"
End If
which returns the object subform isn't known...


If Oefening is the name of the subform ***control***, which
might not be the name of the form object that is being
displayed, then the syntax would be:
Me!Oefening.Form.Filter = "PSY"

But that won't do anthing useful. The Filter property needs
to be set to a Where clause (without the word Where).
Normally, it would be the name of a field in the form's
record source table/query followed by a comparison operator
(=, >, <, etc) and a value of the same type as the field.
For example:
Me!Oefening.Form.Filter = "somefieldname = 'PSY' "
 
A

Allen Browne

If the subform is named oefening, use:
Me!oefening.Form.Filter = "[SomeField] = ""PSY""
Me!oefening.Form.FilterOn = True

Note:
1. Substitute the name of the matching field in the subform for SomeField.
2. There is a bug in Access if you apply filters to the main form and
subform:
http://allenbrowne.com/bug-02.html

You may be able to do this without applying a filter.
Set the LinkMasterFields property of the subform control to:
kader25
Set the LinkChildFields property to the matching field in the subform, e.g.:
SomeField
No code needed.
 
J

JEPE

Thank you both... the "no-code-solution" opens new perspectives...I never
used it before but it's VERY useful.. Thanks
JP-Belgium
Allen Browne said:
If the subform is named oefening, use:
Me!oefening.Form.Filter = "[SomeField] = ""PSY""
Me!oefening.Form.FilterOn = True

Note:
1. Substitute the name of the matching field in the subform for SomeField.
2. There is a bug in Access if you apply filters to the main form and
subform:
http://allenbrowne.com/bug-02.html

You may be able to do this without applying a filter.
Set the LinkMasterFields property of the subform control to:
kader25
Set the LinkChildFields property to the matching field in the subform, e.g.:
SomeField
No code needed.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Jean-Paul De Winter said:
Hi,
I have a form with a subform
The main form has a selectiongroup with 6 items
the subform should be based upon the choise I made in this selectiongroup


The subgroups name is kader25
the subform=oefening

as code I wrote

If Me!Kader25 = 1 Then
Me!SubForm.Form!Oefening.Filter = "PSY"
End If
which returns the object subform isn't known...

What is the correct syntax?
Thanks
JP
 

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