Filter by information in a subform

corai

Registered User.
Local time
Today, 20:58
Joined
Jun 10, 2011
Messages
24
Hi all,

I have a quick question about filtering the items on a form by a control in a subform. I am attempting to use a macro (represented by a button on the form) to achieve this but keep getting an error message which states that the "action requires a valid control name that corresponds to a subform or subreport".

My control name is set up in the following format:
[Forms]![ParentFormName]![SubFormName].[Form]![SubFormControl]


Has anyone encountered this problem before?
 
I use this same code on numerous form hence With CodeContextObject.

Two conditions need to be meet, the Artist must be present and the Stock Number on the subForm must be present (isNumeric). The first function sorts out each Stock record, multiple pages with different Stock numbers:

Code:
Private Function ArtistsStockNo()

    With CodeContextObject
        If IsNumeric(.[Artist Code]) Then
            If .IsNumeric(.[Artists Originals].[Form]![Orig Old Stock]) Then
                ArtistsStockNo = "[Orig Old Stock] = " & .[Artists Originals].[Form]![Orig Old Stock]
            Else
                ArtistsStockNo = 0
            End If
        End If
    End With

End Function

Now that you got the record open a form:
Code:
Function Artists_StockEntry()

            If ArtistsStockNo > 0 Then
                    DoCmd.OpenForm "Originals Entry", acNormal, "", ArtistsStockNo, , acWindowNormal
            End If
End Function

This is a cut down version for simplicity

Simon
 

Users who are viewing this thread

Back
Top Bottom