Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

where clause for vbcrlf 2

Status
Not open for further replies.

edpatterson

IS-IT--Management
Feb 24, 2005
186
I am attempting to query records out of a database which have a crlf in one of the fields. I am using ado and vbscript.

The string is in the form of:

"192.169.1.2&vbcrlf&192.168.1.3&vbcrlf&192.168.1.4"

It is actually the IP_ADDRESS column as saved by BGInfo when selecting a Microsoft Access database.

Tried
[tt]
select ip_address from bginfotable where ipaddress = '%vbcrlf%'
select ip_address from bginfotable where ipaddress = '*vbcrlf*'
select ip_address from bginfotable where ipaddress = '%chr(10)%'
select ip_address from bginfotable where ipaddress = '*chr(10)*'
[/tt]

As you can probably see, I am fairy new to this.

Thanks.
 
erm, so the string actually contains the literal characters of &vbcrlf or line breaks?

if the former, then search for '%vbcrlf%', if the latter, search for '%' & chr(10) & chr(13) & '%'

p.s. line breaks can be either chr(10), chr(13) or both, so you may have to test for each individually...

--------------------
Procrastinate Now!
 
If you are searching with-in the field the SQL you need to use LIKE not =

Code:
SELECT IP_ADDRESS FROM BGINFOTABLE WHERE IP_ADDRESS LIKE "*vbcrlf*"

If you are using VB and ADO you may need to change the * to % and you may need single quotes around the *vbcrlf* (as below), but the Jet SQL is as above.

Code:
strSQL = "SELECT IP_ADDRESS FROM BGINFOTABLE WHERE IP_ADDRESS LIKE '%vbcrlf%'"

What Crowley posted still holds true regarding how the vbcrlf is actually stored.


There are two ways to write error-free programs; only the third one works.
 
Thanks to all. I am using
[tt]
...'%" & (Chr(13) + Chr(10)) & "%'...
[/tt]
and it is working like a champ.

 
If the WHERE clause is built in VBA:
...'%" & vbCrLf & "%'...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top