filtering subform with textbox (1 Viewer)

suraiya

New member
Local time
Yesterday, 16:15
Joined
Nov 19, 2015
Messages
2
Apologises if there are existing threads, I have tried searching for one!

I am trying to filter sub form with in a form using a text box, I have been able get something to work but it just seems to override the first ID with the ID being entered.

I have attached example of the book control database

Thank you soon much
 

Attachments

  • NewControl.accdb
    1.5 MB · Views: 48

Ranman256

Well-known member
Local time
Yesterday, 19:15
Joined
Apr 9, 2015
Messages
4,339
user enters text into the filter box, then enter,
the sub table records then filter.
erase the textbox to get all records back.

Code:
sub txtBox_afterupdate()
if isNull(txtBox) then
   me.filterOn = false
else
   me.filter = "[field]='" & txtBox & "'"
   me.filterOn = true
endif
end sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:15
Joined
Sep 21, 2011
Messages
14,238
That is how it generally works if you just use Linked fields?

One way is that the main form needs to be unbound and pageid linked to bookid.

If you wanted more than one then you could use a multi select listbox?, in fact a listbox is better for this, incase you mistype the bookid ?

I cannot change the db, as I only have 2007. Sorry.
 

suraiya

New member
Local time
Yesterday, 16:15
Joined
Nov 19, 2015
Messages
2
Thank you so much everyone :) it worked perfectly!

When I checked it again, its controlling the sub form but its still change the id in my control table.
 
Last edited:

Users who are viewing this thread

Top Bottom