simple if/then query

M

michael munson

I want to make a VERY simple query. I have a fieldname [web] which
contains URLs. Unfortunately, some of the fields contain data
formatted as www.website.com and some are http://www.website.com I
need all records to have http:// before the website address.

I can't seem to make the query work to make all fields be consistent.
I tried the following (but it resulted in putting http:// in front of
EVERY record... so the ones that already began with http:// had two.)

web2: IIf([web] Like "http://",[web],"http://"+[web])

How can i restructure this (or do something else) to make all my
fields consistent?

thanks.

michael munson
(e-mail address removed)
 
L

Lynn Trapp

Use a criteria with the LIKE operator:

WHERE [Web] LIKE "*" & [Enter Website] & "*"
 
J

John Vinson

I want to make a VERY simple query. I have a fieldname [web] which
contains URLs. Unfortunately, some of the fields contain data
formatted as www.website.com and some are http://www.website.com I
need all records to have http:// before the website address.

I can't seem to make the query work to make all fields be consistent.
I tried the following (but it resulted in putting http:// in front of
EVERY record... so the ones that already began with http:// had two.)

web2: IIf([web] Like "http://",[web],"http://"+[web])

How can i restructure this (or do something else) to make all my
fields consistent?

The LIKE operator recognizes wildcards such as * - but if the string
does not have any wildcards, it is identical to the = operator.

Try

IIf([Web] LIKE "http://*", [Web], "http://" & [web])


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top