473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Apply filter

Hi all,
A form based on a query (qry_source_trailers) contains the field
[bookref]. In the forms header, I have placed an unbound text box where the
afterupdate property is set to:
DoCmd.ApplyFilter , "bookref = forms!frm_trailers!txt_find_bref" This works
fine but I would like to change the filter property to Like instead of
equals due to some of the booking references being very long.

I've tried DoCmd.ApplyFilter , "bookref like " *
"&forms!frm_trailers!txt_find_bref&" * "" which throws up a type mis-match.
Could anyone offer any guidance?

TIA,

Mark
Nov 13 '05 #1
2 3740
Assuming bookref is a Text field (not a Number field), try:
Dim strWhere As String
strWhere = "bookref like """*" & forms!frm_trailers!txt_find_bref &
"*"""
DoCmd.ApplyFilter , strWhere

The odd quotes are because you need to end up with a string that looks like
this:
bookref Like "*peace*"
and you have to double-up the quotes when they are embedded. To help get it
right, you could:
Debug.Print strWhere
and then look in the Immediate Window (Ctrl+G) after it runs.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mark" <ma*********@ntlworld.com> wrote in message
news:Tl*************@newsfe1-gui.ntli.net...

A form based on a query (qry_source_trailers) contains the field
[bookref]. In the forms header, I have placed an unbound text box where
the afterupdate property is set to:
DoCmd.ApplyFilter , "bookref = forms!frm_trailers!txt_find_bref" This
works fine but I would like to change the filter property to Like instead
of equals due to some of the booking references being very long.

I've tried DoCmd.ApplyFilter , "bookref like " *
"&forms!frm_trailers!txt_find_bref&" * "" which throws up a type
mis-match.
Could anyone offer any guidance?

Nov 13 '05 #2
Many thanks for your help and explanation again Allen. Worked a treat.

Regards,

Mark

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
Assuming bookref is a Text field (not a Number field), try:
Dim strWhere As String
strWhere = "bookref like """*" & forms!frm_trailers!txt_find_bref &
"*"""
DoCmd.ApplyFilter , strWhere

The odd quotes are because you need to end up with a string that looks
like this:
bookref Like "*peace*"
and you have to double-up the quotes when they are embedded. To help get
it right, you could:
Debug.Print strWhere
and then look in the Immediate Window (Ctrl+G) after it runs.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mark" <ma*********@ntlworld.com> wrote in message
news:Tl*************@newsfe1-gui.ntli.net...

A form based on a query (qry_source_trailers) contains the field
[bookref]. In the forms header, I have placed an unbound text box where
the afterupdate property is set to:
DoCmd.ApplyFilter , "bookref = forms!frm_trailers!txt_find_bref" This
works fine but I would like to change the filter property to Like instead
of equals due to some of the booking references being very long.

I've tried DoCmd.ApplyFilter , "bookref like " *
"&forms!frm_trailers!txt_find_bref&" * "" which throws up a type
mis-match.
Could anyone offer any guidance?


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Themis Parintas ste kardias | last post by:
How can i apply a filter on a form on a field with text when i select from a combo box
16
by: Nhmiller | last post by:
I already have a report designed under Reports. When I use filtering in Forms or Tables, I see no way to select that filtered list when I am in Reports, and there appears to be no way to do the...
4
by: Iyhamid | last post by:
Hi I am looking for codes to filter and apply filter to my data base using access
3
by: mattscho | last post by:
Hi All, Trying to create a set of 3 buttons in a form that have the same effect as the "Filter by Form", "Apply Filter" and "Remove Filter" Buttons on the access toolbar. Help would be muchly...
1
by: mattscho | last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form. -------------------------------------------------------------------------------- Hi All, Trying to create a set of 3 buttons in...
9
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to open a text file and format it into a specific line and then apply color to a specific location of the text and then display it in a RichTextBox after all of this is done. I can do all...
1
by: eHaak | last post by:
A couple years ago, I built a database in MS Access 2003. I built the form using macros in some of the command buttons, and now I’m trying to eliminate the macros and just use visual basic code. ...
3
by: dbdb | last post by:
hi guys need your suggestion how can i apply filter for my date variable data type i have a form name transaction and i have a text box on it named : start and finish i need to apply...
10
by: dbdb | last post by:
Hi, i create a chart in ms access based on my query, then i want my chart when is it open is only show value based on my criteria. i'll try to used it in the properties apply filter using the...
5
by: phill86 | last post by:
Hi, I have a form that I have applied a filter to by using combo boxes which works fine. Is there a way to apply that filter to the forms underlying query Here is the code that I use to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.