473,396 Members | 1,895 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,396 software developers and data experts.

String sql problem

Hi
I build string sql in this way:

For Each varItem In Me!Lstclient.ItemsSelected
strCriteria = strCriteria & "tbltable1.client = " & Chr(34)
_
& Me!Lstclient.ItemData(varItem) & Chr(34) &
"OR "
Next varItem

strSQL = "SELECT * FROM tbltable1 " & _
"WHERE " & strCriteria & ";"

Unfortunately when the name of client is with "" ( for example "SONY" )
it causes error.
I tryied in many ways with "'" but cannt to handle with this problem.
Maybe someone can give me a little help.
Thanks

Piter

Mar 13 '06 #1
1 1316

"Piter" <to**@wp.pl> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Hi
I build string sql in this way:

For Each varItem In Me!Lstclient.ItemsSelected
strCriteria = strCriteria & "tbltable1.client = " & Chr(34)
_
& Me!Lstclient.ItemData(varItem) & Chr(34) &
"OR "
Next varItem

strSQL = "SELECT * FROM tbltable1 " & _
"WHERE " & strCriteria & ";"

Unfortunately when the name of client is with "" ( for example "SONY" )
it causes error.
I tryied in many ways with "'" but cannt to handle with this problem.
Maybe someone can give me a little help.
Thanks

Piter

Strangely enough, I answered an almost identical question just a couple of
minutes ago. Something like this should do it:
Private Sub DoTest()

On Error GoTo Err_Handler

Dim strValue As String
Dim strWhere As String
Dim varSelected As Variant
Dim strSQL As String

With Me.lstClient

For Each varSelected In .ItemsSelected
strValue = CStr(.Column(0, varSelected))
strValue = Replace(strValue, """", """""")
strWhere = strWhere & ",""" & strValue & """"
Next varSelected

End With

If Len(strWhere) > 0 Then
strWhere = Mid$(strWhere, 2)
strWhere = " WHERE Client (" & strWhere & ")"
End If

strSQL="SELECT * FROM tbltable1" & strWhere
Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

Mar 13 '06 #2

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

Similar topics

7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
17
by: Olivier Bellemare | last post by:
I've tried to make a function that returns the middle of a string. For example: strmid("this is a text",6,4); would return "is a". Here is my code: char *strmid(char *texte, int depart,...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
4
by: MooMaster | last post by:
After some google searching on the forum I couldn't find any topics that seemed to relate exactly to my problem, so hopefully someone can help me out... I'm running python 2.4.1 on a local Win2K...
6
by: tommaso.gastaldi | last post by:
Hi, does anybody know a speedy analog of IsNumeric() to check for strings/chars. I would like to check if an Object can be treated as a string before using a Cstr(), clearly avoiding the time...
5
by: ThatVBGuy | last post by:
Hello All, I could really use some help with this problem its driving me nuts. I have a small vb app, the goal of the app is to read an html doc into a variable then go through that variable and...
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.