look in 4 fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all!

I have a very stupid question:
I have 4 macros which set filters for my form with conditions:
[ST_ToFrom]![ToFrom] Like ("*"+[Enter Name]+"*")

[ST_ToFrom]![TF] Like ("*"+[Enter Name]+"*")

[ST_ToFrom]![Address] Like ("*"+[Enter Name]+"*")

[ST_ToFrom]![AccName] Like ("*"+[Enter Name]+"*")

I wonder if i can combine them all in 1 macro? (all 4 fields are text)
Tried to use "OR" - but it wouldnt work....

Can somebody please help me?

Thank you.
Lana
 
Lana,

Can you please provide more details of what you are doing? I'm afraid I
can't understand what you mean. Are the expresssions you gave us in a
macro Condition? If so, what are the actions they qualify? If not, what
are the actions in the macro, and how are these expressions being used?
What does [ST_ToFrom] refer to? Where is the macro being called from?
 
I have a form for data input. I want to be able to filter out records (find
them and display results in the same form).

presently on my form i have 4 buttons with 4 macros which run those filters.

each macro looks as follows:
apply filter where the condition is
[ST_ToFrom]![ToFrom] Like ("*"+[Enter Name]+"*")

All 4 look very similar and i was wondering if i can have 1 button with only
1 macro which will look in all 4 fields and display all the records where
condition is met.

[ST_ToFrom] - is the name of the table

Thank you.
Lana


Steve Schapel said:
Lana,

Can you please provide more details of what you are doing? I'm afraid I
can't understand what you mean. Are the expresssions you gave us in a
macro Condition? If so, what are the actions they qualify? If not, what
are the actions in the macro, and how are these expressions being used?
What does [ST_ToFrom] refer to? Where is the macro being called from?

--
Steve Schapel, Microsoft Access MVP

Hi all!

I have a very stupid question:
I have 4 macros which set filters for my form with conditions:
[ST_ToFrom]![ToFrom] Like ("*"+[Enter Name]+"*")

[ST_ToFrom]![TF] Like ("*"+[Enter Name]+"*")

[ST_ToFrom]![Address] Like ("*"+[Enter Name]+"*")

[ST_ToFrom]![AccName] Like ("*"+[Enter Name]+"*")

I wonder if i can combine them all in 1 macro? (all 4 fields are text)
Tried to use "OR" - but it wouldnt work....

Can somebody please help me?

Thank you.
Lana
 
Lana,

Ok, thanks for the further information.

As I understand it, you want an ApplyFilter action in a macro where the
criteria can be related in the Where Condition argument to any of the 4
fields in the form, am I right? You mentioned that you had tried using
'Or' in the expression, which is the correct approach, so it is very
puzzling why this didn't work for you. Since this macro is being
applied on a form, you don't need the table name. And you should use &
as your concatenation character instead of the +, which in this case
only works by a fluke. So, something like this, I suppose...
[ToFrom] Like "*" & [Enter Name] & "*" Or [TF] Like "*" & [Enter Name]
& "*" Or ... etc

Any good?
 
Thank you so much Steve!! It does work :)
I was stupid to put "OR" in the wrong place :)
[ST_ToFrom]![ToFrom] OR [ST_ToFrom]![TF] Like ("*"+[Enter Name]+"*")

but when i put it as u suggested
[ST_ToFrom]![ToFrom] Like ("*"+[Enter Name]+"*") OR [ST_ToFrom]![TF] Like
("*"+[Enter Name]+"*")
- it worked immediately :)

Thanx a lot again again,
Lana


Steve Schapel said:
Lana,

Ok, thanks for the further information.

As I understand it, you want an ApplyFilter action in a macro where the
criteria can be related in the Where Condition argument to any of the 4
fields in the form, am I right? You mentioned that you had tried using
'Or' in the expression, which is the correct approach, so it is very
puzzling why this didn't work for you. Since this macro is being
applied on a form, you don't need the table name. And you should use &
as your concatenation character instead of the +, which in this case
only works by a fluke. So, something like this, I suppose...
[ToFrom] Like "*" & [Enter Name] & "*" Or [TF] Like "*" & [Enter Name]
& "*" Or ... etc

Any good?

--
Steve Schapel, Microsoft Access MVP
I have a form for data input. I want to be able to filter out records (find
them and display results in the same form).

presently on my form i have 4 buttons with 4 macros which run those filters.

each macro looks as follows:
apply filter where the condition is
[ST_ToFrom]![ToFrom] Like ("*"+[Enter Name]+"*")

All 4 look very similar and i was wondering if i can have 1 button with only
1 macro which will look in all 4 fields and display all the records where
condition is met.

[ST_ToFrom] - is the name of the table

Thank you.
Lana
 
Back
Top