Filter problem

geregs

I@mac
Local time
Today, 22:54
Joined
Feb 27, 2008
Messages
20
Hi All!
Thanks again Bob! It really helped me.
I wondered, if you could help me something connected to the last question.
I created a form and one text box on it for the filter and a command button for the filter. Everything works great with filter but I would like to use the same text box to use the filter again but not to lose previous filter (filter on filter).
I tried like this:

Dim Filtika As String
If Me.FilterOn = True Then
Me.Filter = Filtika
Me.Filter = "[myfieldname] = '" & Me![mytextboxname] & "' And Filtika"
Me.FilterOn = True
Else
Me.Filter = "[myfieldname] = '" & Me![mytextboxname] & "'"
Me.FilterOn = True
End If

But with no result
Thanks in advance
 
Simple Software Solutions

No Bob, but looking at your syntax you need to revise you If Statement

Me.Filter = "[myfieldname] = '" & Me![mytextboxname] & "' And Filtika"

Should read

Me.Filter = "[myfieldname] = '" & Me![mytextboxname] & "' And " & Filtika

Ok

CodeMaster::cool:
 
still problem

Thanks, but when I try with this code:

Dim filtika as String
If Me.FilterOn = True Then
Me.Filter = Filtika
Me.FilterOn = False
Me.Filter = "[myfieldname] = '" & Me![mytextboxname] & "' And filtika"
Me.FilterOn = True
Else
End If

I get the pop up with the message "enter parameter value" for "filtika"

but when I try this code:

Dim Filtika As String
If Me.FilterOn = True Then
Me.Filter = Filtika
Me.FilterOn = False
Me.Filter = "[myfieldname] = '" & Me![mytextboxname] & "' And " & Filtika
Me.FilterOn = True
Else
End If

I get a pop up "you cant assign a value to this object"
What to do?

Thanks in advance!
 
Simple Software Solutions

Ok

You are Dimming filtika As String at the beginning of the code snippet.

Then you are stating Me.Filter = filtika

At this point you have not assigned anything to this variable.

So in effect you filter string ends with the word And

You need to declare the varable earlier on in the code, I suggest at the main form declarations stage so it is available throughout the life of the open form.

So if the filter was previously set the filtika will have a valid string. One thing to bear in mind is what happens if the earlier filter relates to FieldA and a filter is applied. Then the user enters another filter using FieldA again. Your new filter string will have two conditions applied to the same field.

CodeMaster::cool:
 
Stillll Problem!

Thanks DCrake....
I tried it, but it still do not work!
Here is the base so if you could just check it for a moment.....

Thankssssssss!!!!:):):):):)
 

Attachments

Simple Software Solutions

Ok

Task 1
Move the dim statement from the OnFormLoad event to the main declarations (above)

Task 2
Paste the following code into the OnClick Event of your filter button

filtika = filtika & " OR [Sifra]= '" & Me!TextFiltera & "'"
If Left(filtika, 4) = " OR " Then
filtika = Mid(filtika, 4)
End If

DoEvents
Me.filter = filtika
Me.FilterOn = True


Task 3
Paste the following into your OnClick Event of your clear filter button
filtika = ""
Me.FilterOn = False

Save changes and exit

Load form

Enter 256 and click filter button
Enter 2222 and click filter button


CodeMaster::cool:
 
Thanks!!!

I modified it a little AND IT IS WORKING !!!!
This is the modification:
filtika = filtika & " and [Sifra]= '" & Me!TextFiltera & "'"
If Left(filtika, 5) = " and " Then
filtika = Mid(filtika, 5)
End If
Me.filter = filtika
Me.FilterOn = True

Thanks DCrake :):):):):):):):):):)
 

Users who are viewing this thread

Back
Top Bottom