Access can't find the 'FrmLookup' referred to in your expression in a form (1 Viewer)

Coldsteel

Registered User.
Local time
Today, 01:06
Joined
Feb 23, 2009
Messages
73
Hello all,
I keeping a the error (Access can't find the 'FrmSearch' referred to in your expression in a form) Can anyone point me in the right direction. Here is my code:

Private Sub Search_Click()

Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String

strWhere = "1=1"

If Not IsNull(Me.txtTellerNum) Then
'Create Predicate
strWhere = strWhere & " AND " & "QryFind.[Person] = " & Me.txtTellerNum & ""
End If

If Nz(Me.StatusSRH) <> "" Then
strWhere = strWhere & " AND " & "QryFind.[Type] = '" & Me.StatusSRH & "'"
End If

If strError <> "" Then
MsgBox strError
Else

acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
End If
Me!FrmLookup.Form.Filter = strWhere
Me!FrmLookup.Form.FilterOn = True
End If
End Sub
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 17:06
Joined
Jan 20, 2009
Messages
12,849
Is FrmLookup the name of the subformcontrol on Me?

This control is what must be referenced and it may have a different name from the form that is its SourceObject.
 

Coldsteel

Registered User.
Local time
Today, 01:06
Joined
Feb 23, 2009
Messages
73
Thanks for the help,
FrmLookup is the name of the subformcontrol. I am not to sure what you mean, can you provide me a example.

Thanks
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 17:06
Joined
Jan 20, 2009
Messages
12,849
SourceObject is a property of the subformcontrol and refers to the form object displayed in the subformcontrol. The subform wizard anmes the control to match the form object but it doesn't have to be the same.

If the name of the control is correct then that line should be working.

BTW There is no point ot testing if the footer is visible. Just set it to visible regardless.
 

Coldsteel

Registered User.
Local time
Today, 01:06
Joined
Feb 23, 2009
Messages
73
Thanks again for the help, I set the footer to visible, and I tried the long way to name my sub-form (Forms![form name]![control name].Form.[control name]), but I still get the same error.
 

Coldsteel

Registered User.
Local time
Today, 01:06
Joined
Feb 23, 2009
Messages
73
I tried the exact same code but, I used a Table for instead of a Query as the subforms' record source and it works, but is there a way for me to use a Query instead?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 17:06
Joined
Jan 20, 2009
Messages
12,849
You have a reference to the form in the query.

However that reference is directly to the form via the Forms Collection rather than its instance in the subform.
 

Users who are viewing this thread

Top Bottom