UtterAccess.com
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    
 
   
Miguel_A
post Oct 20 2019, 12:56 PM
Post#1



Posts: 250
Joined: 20-January 04



Hi

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 :

QUOTE
Set dbs = CurrentDb

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


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

QUOTE
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: 2
 
Go to the top of the page
 
theDBguy
post Oct 20 2019, 01:02 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,606
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
 
Miguel_A
post Oct 20 2019, 01:16 PM
Post#3



Posts: 250
Joined: 20-January 04



hi

Thanks for the very fast reply...

So my second approaxy should have worked ?

I mean despite i had after a
CODE
'Me!Sub_Form_Data.Requery
, 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
 
Miguel_A
post Oct 20 2019, 04:07 PM
Post#4



Posts: 250
Joined: 20-January 04



Hi

Just found the bug on it

QUOTE
Private Sub Texto_Nome_Force_Change()
On Error GoTo errHandler

'thedbguy@gmail.com
'10/20/2019
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
Else
Me.Sub_Form_Data.Form.Filter = ""
Me.Sub_Form_Data.Form.FilterOn = False
End If
Exit Sub
errHandler:
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    21st November 2019 - 07:34 PM