Re: OpenForm with Where Clause
- From: "Mike Charney" <nothing@xxxxxxxxxxxxxx>
- Date: Tue, 04 Apr 2006 14:32:06 GMT
So how would I do a pattern match on a field that had data like DMH10257 or
DMH10096?
Mike
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:4432812e$0$2141$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Matching numbers based on the string value of the digits is not generally
useful. For example:
Like "1*"
matches 1, 10, 11, ... 19, 100, 101, ...
which is not really a useful sequence of numbers.
Access will do it, but it is not normally a good design.
--
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.
"Mike Charney" <nothing@xxxxxxxxxxxxxx> wrote in message
news:FZuYf.55326$F_3.45096@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
So what happens if I have a text field with numbers in it? Can I use the
str( ) function to change the number to a string, and will it still
search on the filed?
Mike
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:4431c200$0$2149$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Use the Like operator with Text type fields (not dates or numbers.)
Text fields need quotes as delimiters.
Use * as the wildcard, or % if the back end is Sql Server.
Example:
Dim strWhere As String
If Not IsNull(Me.txtFindCity) Then
strWhere = "(City Like ""*" & Me.txtFindCity & "*"")"
End If
If you want an example of how to filter a form based on any combination
of unbound search controls on different types of fields, try:
http://allenbrowne.com/unlinked/Search2000.zip
The example requires Access 2000 or later. The code is documented, but
there is no explanatory article.
"Mike Charney" <nothing@xxxxxxxxxxxxxx> wrote in message
news:olcYf.61747$H71.973@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks Allen,
That took care of the between condition I needed. Do you know anything
about the Like condition in the where clause?
Mike
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:44313f26$0$2151$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Check out the example code for Method 2 in this article:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
The code explains how to build the WhereCondition based on whichever
boxes have an entry. You do exactly the same thing for OpenForm as it
explains for OpenReport.
"Mike Charney" <nothing@xxxxxxxxxxxxxx> wrote in message
news:fXaYf.63820$Jd.3267@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am trying to write an Open Form command in VBA with a where clause
in it.
I need to be able to do two different where clauses:
1) With a between in it: i.e. Between Date1 and Date2 or Between
Data1 and Data2
2) With a Like in it: Like *data1* or Like *date1*
3) Or a statement with both Between and Like in it.
I do not know how to make these statements?
.
- Follow-Ups:
- Re: OpenForm with Where Clause
- From: Allen Browne
- Re: OpenForm with Where Clause
- References:
- OpenForm with Where Clause
- From: Mike Charney
- Re: OpenForm with Where Clause
- From: Allen Browne
- Re: OpenForm with Where Clause
- From: Mike Charney
- Re: OpenForm with Where Clause
- From: Allen Browne
- Re: OpenForm with Where Clause
- From: Mike Charney
- Re: OpenForm with Where Clause
- From: Allen Browne
- OpenForm with Where Clause
- Prev by Date: Re: unknown message recipient(s)
- Next by Date: Re: Trouble with DAO "SEEK" in converting application to SQL Express back end.
- Previous by thread: Re: OpenForm with Where Clause
- Next by thread: Re: OpenForm with Where Clause
- Index(es):
Relevant Pages
|
|