Solved Query search filter for a form linked to navigation button on Main form (1 Viewer)

Ihk

Member
Local time
Today, 11:54
Joined
Apr 7, 2020
Messages
280
I have continuous form with records, I want to filter.
Continuous form (Articleform) datasource is query. I am using query filter as we use it for list boxes using following criteria.
Code:
Like "*" & [forms]![ArticleForm]![txtSearch] & "*"
And form has unbound text field being used for text to filter, as you type.
This criteria works perfectly fine when I type any text directly on this form. (offcourse with extra piece of code for search field, given below)
Problem:
This continuous form (ArticleForm) is linked to a "Mainform" which is dashboard which is naviation form with navigation buttons.
How to path above query criteria, I tried several ways including "Mainform" name inside or navigation button name inside as well but it keeps popping up dialogue box.
My tries
Code:
Like "*" & [forms]![ArticleForm]![Mainform]![txtSearch] & "*"
Code:
Like "*" & [forms]![ArticleForm]![Navigationbutton154]![txtSearch] & "*"
etc ways, but did not work.

for reference (if some one needs to know):
form top
Code:
Option Compare Database
Option Explicit
Private blnSpace As Boolean
text search field on change
Code:
Private Sub txtSearch_Change()
If blnSpace = False Then
Me.Requery
Refresh
txtSearch.SetFocus
txtSearch.SelStart = Len(Me.txtSearch.Text)
End If
End Sub
on key press
Code:
Private Sub txtSearch_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
  blnSpace = True
Else
  blnSpace = False
End If
End Sub
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 02:54
Joined
Oct 29, 2018
Messages
21,467
Hi. Not sure if you're saying the continuous form is a subform to a subform in a navigation form, or if you're saying the continuous form is a subform to a navigation form. In any case, the usual syntax would be something like:

Forms!MainFormName.SubformContainerName.Form!TextboxName

Hope that helps...
 
  • Love
Reactions: Ihk

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,230
same as post#2

Forms!NavigationFormName!NavigationSubformName!txtSearch

you'll get error still when the Tab where ArticleForm is not Currently in focus
because there can only be one "form" object inside NavigationSubform at a time.
 
  • Love
Reactions: Ihk

Ihk

Member
Local time
Today, 11:54
Joined
Apr 7, 2020
Messages
280
Thank you very much @theDBguy and @arnelgp , for helping me out.
It worked perefect with "SubformContainerName" but not with NavigationSubformName... as Post#2
Kind regards,
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,230
that is if you Renamed your NavigationSubform to another name?
 

Ihk

Member
Local time
Today, 11:54
Joined
Apr 7, 2020
Messages
280
that is if you Renamed your NavigationSubform to another name?
Okay I got it now, but I thought "NavigationSubformName" you meant the name of the subform linked to navigation button.
I have not renamed it, all navi containers have default name "NavigationSubform"
Now working code is
Code:
Like "*" & [Forms]![MainForm].[NavigationSubform].[Form]![txtSearch] & "*"

Thank you very much. Kind regards,
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,230
you meant the name of the subform linked to navigation button
that is the "form" (source object) of your navigation button.

if you initially build your Navigation form, the Original name of the navigation subform is NavigationSubform
 
  • Love
Reactions: Ihk

Users who are viewing this thread

Top Bottom