X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Sub-form Filter Not Working, Access 2016    
post Oct 20 2019, 12:56 PM

Posts: 250
Joined: 20-January 04


Once more i come here to ask for some help on this database issue.
Did change a little bit since yesterday, instead 2 sub-form on a main form it's only one (a continuous sub-form).

So the idea is for when i press on any of the input's text on the main form he will filter true the sub-form, however and for testing purposes i am only filtering for one field.

This is the code i am using for the filter :

Set dbs = CurrentDb

sqlText = "SELECT * FROM DadosTable WHERE Nome='teste'"
dbs.OpenRecordset (sqlText)

just a simple query, however it's not doing nothing not even trowing a error.
After googling allot did find out there is a second methond of filtering but however it's not doing nothing as well

Me!Sub_Form_Data.Form.Filter = "[Texto_Nome] = teste"
Me!Sub_Form_Data.Form.FilterOn = True

I will leave you with the database file.
I am sure you guys will find why this, but usually i only ask stuff after googling allot and , been almost 2 hours on that 5 lines of code, ufff.

Thanks in advance
Attached File(s)
Attached File  Database.zip ( 168.36K )Number of downloads: 3
Go to the top of the page
post Oct 20 2019, 01:02 PM

UA Moderator
Posts: 77,485
Joined: 19-June 07
From: SunnySandyEggo

Take a look at the attached. And to give you more ideas, have a look in the Code Archive.

Attached File(s)
Attached File  Database2.zip ( 39.65K )Number of downloads: 8

Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
post Oct 20 2019, 01:16 PM

Posts: 250
Joined: 20-January 04


Thanks for the very fast reply...

So my second approaxy should have worked ?

I mean despite i had after a
, after a while i did took that out thinking that might be because of it.
This is just weird grrrr.

Anyway now that i know that is correct i will work on it, thanks.

One more thing, any idea why after i open the file and the form and if i start writing on the input the filter will not work ?
in order to work (for some reason) i have to click in any other form and click back again on the input and start writing.

Thanks in advance
Go to the top of the page
post Oct 20 2019, 04:07 PM

Posts: 250
Joined: 20-January 04


Just found the bug on it

Private Sub Texto_Nome_Force_Change()
On Error GoTo errHandler

If Trim(Me.Texto_Nome_Force.Text) > "" Then
Me.Sub_Form_Data.Form.Filter = "Nome Like '" & Me.Texto_Nome_Force.Text & "*'"
Me.Sub_Form_Data.Form.FilterOn = True
Me.Sub_Form_Data.Form.Filter = ""
Me.Sub_Form_Data.Form.FilterOn = False
End If
Exit Sub
MsgBox Err.Number & " - " & Err.Description, vbOKOnly, "Error..."
End Sub

Added the Trim function and the used the Text properties instead in that same line.

Thanks in advance
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    18th February 2020 - 06:07 AM