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

Using Replace help please

13
Im using the following code
Expand|Select|Wrap|Line Numbers
  1. queerey = Replace(Text3, "or", "' or OrderID ='")
  2. strSQL2 = "SELECT * FROM tblorder where orderID = '" & queerey & "'"
  3. DoCmd.OpenReport "tblorder1", acViewPreview, strSQL2
  4. MsgBox strSQL2
  5.  
The idea is that the i can enter 1 or 2 for example and they will show in a report which i have got set up but when i output the string it comes out as
SELECT * FROM tblorder where orderID = '1 ' or orderID = ' 2'
which means that it wont work because of the spaces. I have tried it using
Expand|Select|Wrap|Line Numbers
  1. strSQL2 = "SELECT * FROM tblorder where orderID = '1' OR orderID = '2'"
  2.  
and that worked and the only thing different is the spaces.
Mar 5 '08 #1
2 841
VBWheaties
145 100+
Im using the following code
Expand|Select|Wrap|Line Numbers
  1. queerey = Replace(Text3, "or", "' or OrderID ='")
  2. strSQL2 = "SELECT * FROM tblorder where orderID = '" & queerey & "'"
  3. DoCmd.OpenReport "tblorder1", acViewPreview, strSQL2
  4. MsgBox strSQL2
  5.  
The idea is that the i can enter 1 or 2 for example and they will show in a report which i have got set up but when i output the string it comes out as
SELECT * FROM tblorder where orderID = '1 ' or orderID = ' 2'
which means that it wont work because of the spaces. I have tried it using
Expand|Select|Wrap|Line Numbers
  1. strSQL2 = "SELECT * FROM tblorder where orderID = '1' OR orderID = '2'"
  2.  
and that worked and the only thing different is the spaces.
I'm not sure what you are asking or what your issue is.
If you have a space, you can easily replace it.

Expand|Select|Wrap|Line Numbers
  1. 'Use Space function to return 1 length space: 
  2. Var = Replace(Text, Space(1), "")
  3.  
  4. 'heres another way:
  5. Var = Replace(Text, " ", "") 
  6.  
Mar 5 '08 #2
Clant1
13
Cheers mate i didnt think of doing that thanks alot.
Expand|Select|Wrap|Line Numbers
  1. queerey = Replace(Text3, "or", "' or OrderID ='")
  2. queerey = Replace(queerey, Space(1), "")
  3. queerey = Replace(queerey, "or", " Or")
  4. queerey = Replace(queerey, "or der", "order")
  5.  
Thats how it is now if any 1 wants to see the fix. Thanks alot
Mar 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: JSzucs | last post by:
I wrote a little code snipet in Asp.Net to send a default message to my outlook email address. That works fine, since the SMTP virtual server default domain is same domain as my outlook mail...
16
by: Stephane | last post by:
Hi, I'm trying to replace parenthesis using Regex.replace but I'm always having this error: System.ArgumentException: parsing ":-)" - Too many )'s. Parameter name: :-) Here's my code: ...
5
by: Mark | last post by:
Hi All, Is there a way to (whilst using the sendobject command) use a query as the source of email addresses. I ask this because the list is constanly changing and I don't want to keep going into...
2
by: Ermi | last post by:
Hi, i have this problem.... From a visual basic application I must replace the value contained in a column with another one....for example Field1 ------ Alfa Beta Gamma
11
by: Dorsa | last post by:
HI, Could you please tell me the error in here. I am trying to open an XML file from a link. Response.Clear() Response.Expires = 0 Response.BufferOutput = False Response.ContentType =...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
1
by: bsprogs | last post by:
I am currnetly programming a file hosting website in PHP and I am slowly integrating AJAX into the website. Here is my problem: The user uploads the file. The server processes the file and...
11
by: S N | last post by:
how to print apostrophe character ' and double quote " in asp using vbscript. my code using response.write replaces " character with inverted question mark. please help
4
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi All, Our company is merging two production domains(from two different servers) onto one server. So during the migration we use an intranet testing server to hold all files from these two...
0
by: =?Utf-8?B?UG9sbHkgQW5uYQ==?= | last post by:
Hi, I have previously used EL v 3.1 Exception Handling application block successfully. I thought I would now try to do the same with EL v 4.0. My first experiment was to replace an exception....
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.