472,794 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Using LIKE with IF....

Hi,

I have a recordset which pulls out specific customer names.
One of our customers have many branches, i.e:
Customer A Site 1
Customer A Site 2
Customer A Site 3
etc.....

I have the following IF statement, and want to catch all of the Customer A names...

If RS("CustomerName") like Customer A * then........

I just want to catch all customer names starting with 'Customer A'.

I'm sure this statement will work, i'm just missing a quote or something ??

Appreciate your help

David
Jul 21 '05 #1
3 1137
Why don't you do this IN THE QUERY instead of while processing the results?

You didn't mention what database you're using, but in SQL Server,

SELECT
Customer, site
FROM wherever
WHERE Customer LIKE 'Customer A%'

This reduces the amount of network chatter and lets the engine use an index
instead of returning all the data (often a more expensive table scan).

However, if you insist that you want to do this in ASP, and just throw away
the rest of the rows, then you can't use LIKE. LIKE is a SQL operator, not
present in VBScript.

strLike = "Customer A"
strLen = Len(strLike)
do while not rs.eof
strDB = rs("CustomerName")
if left(lcase(strDB), strLen) = lcase(strLike) then
........
end
rs.movenext
loop

However, I might suggest that your design is flawed, if all 'Customer A%'
are the same customer, then perhaps you should be using a master table and
inserting the ID of the customer instead...

--
http://www.aspfaq.com/
(Reverse address to reply.)


"David" <da***@scene-double.co.uk> wrote in message
news:c1**************************@posting.google.c om...
Hi,

I have a recordset which pulls out specific customer names.
One of our customers have many branches, i.e:
Customer A Site 1
Customer A Site 2
Customer A Site 3
etc.....

I have the following IF statement, and want to catch all of the Customer A names...
If RS("CustomerName") like Customer A * then........

I just want to catch all customer names starting with 'Customer A'.

I'm sure this statement will work, i'm just missing a quote or something ??
Appreciate your help

David

Jul 21 '05 #2
If Aaron's suggestion doesn't work look at InStr()

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"David" <da***@scene-double.co.uk> wrote in message
news:c1**************************@posting.google.c om...
Hi,

I have a recordset which pulls out specific customer names.
One of our customers have many branches, i.e:
Customer A Site 1
Customer A Site 2
Customer A Site 3
etc.....

I have the following IF statement, and want to catch all of the Customer A
names...

If RS("CustomerName") like Customer A * then........

I just want to catch all customer names starting with 'Customer A'.

I'm sure this statement will work, i'm just missing a quote or something
??

Appreciate your help

David

Jul 21 '05 #3

Aaron,
Cheers,
that did the trick !

Why did'nt I think of something so simple.....Doh !
Great Work
Thanks again.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #4

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

Similar topics

4
by: Marshall Mills | last post by:
As I understand it, loaded statement, a using declaration should be all I need to see an enum from within a namespace. The below code works fine with class, struct, and union. What gives? As the...
17
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example ...
14
by: john.burton.email | last post by:
I've done some extensive searching and can't seem to find an answer to this - Is it correct to using "using" with templates, for example: using std::vector; Or do I need to specify the type...
12
by: Calum Grant | last post by:
In older C++ computer books, you'll often see using namespace std; even in my 1996 copy of Stroustrup. Nowadays, it seems to be considered better to qualify names to make it clearer what...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.