Another post sent when I accidentally pressed Ctl + Enter.
Continuing on
I can see that you are new at this.
The keyword 'Set' can only be used in certain ways, not the way you have
written it.
Where I have written PKey - replace it with the name of the control that has
the value you want to find.
If might be the primary key from the form that the code is running in.
Where you have
Set PKey = "FORM CAT ID"
Set lngPKey = "1"
I would expect something like
lngPKey = Me.CustomerID
strFilter = "[CustomerID] = " & lngPKey
With forms!Main2![NameOfSubformControl].Form
.Filter = strFilter
.FilterOn = True
End With
Note:
Replace [CustomerID] with the name of the control for your forms and tables.
[NameOfSubformControl] means the name of the control on the main form which
has the subform inside it.
The name of the subform can be different from the name of the subform
control.
See how you go using the above ideas, and post back with more questions as
needed.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
"Ryan" <(E-Mail Removed)> wrote in message
news:F88A9CE8-A57F-4214-984C-(E-Mail Removed)...
> Hi Jeanette,
>
> This is what I have, but it errors
>
> Function RMVForms_Admin()
> Forms!Main2!mainsubform.SourceObject = "FORM LIST subform"
>
> Dim strFilter As String
> Dim lngPKey As Long
> Dim PKey As Long
>
> Set PKey = "FORM CAT ID"
> Set lngPKey = "1"
> 'Set strFilter = "[PKey] = """ & lngPKey & """"
> Set strFilter = "[PKey] = " & lngPKey
>
> Forms!Main2!FORM_LIST_subform.FORM_CAT_ID.Form.Filter = strFilter
> Forms!Main2!FORM_LIST_subform.FORM_CAT_ID.Form.FilterOn = True
> 'Forms(FORM_LIST_subform).NameOfSubformControl.Form.FilterOn = True
>
> 'Note: the field being in the above is called PKey.
> 'The value to filter on is lngPKey, where the value for lngPKey will come
> 'from your function in some way.
> 'If that field is a text type, use quotes
> 'strFilter = "[PKey] = """ & lngPKey & """"
>
>
> Forms!Main2.Text20 = "RMV Admin Forms"
> End Function
>
> new at this, and would appreciate some direction with the above code. I
> think...no I know have it buggard up cause it doesn't work for me.
>
> "Main2" is my main form
> "mainsubform" is the unbound subform
> "FORM LIST subform" is the form that is called into the subform
> "FORM CAT ID" is the field that I want to filter based on IngPKey
>
> thanks
> Ryan
|