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

Search code does not work

I have break VBA code but it does not work

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdsearch_Click()
  2.  
  3. Dim strSearch As String
  4.  'Declare the variable strSearch as data type string
  5.  
  6. Dim strText As String
  7.  'Declare the variable strText as data type string
  8.  
  9. strText = Me.txtSearch.Value
  10.  'The value from the text box txtSearch is assigned th
  11.  'the varuable strSearch
  12.  
  13.  strSearch = "SELECT *FROM tblSupplier where ((SupplierID Like ""*" & strText "*"")Or _
  14.  (Company Like ""*" & strText "*"") or (FirstName Like ""*" & strText "*"")Or _
  15.  (LastName Like ""*" & strText "*"") or (BusinessPhoneLike ""*" & strText "*"") Or _
  16.  (Address Like ""*" & strText "*"")or (City Like ""*" & strText "*"")"
  17.  
  18.  
  19. End Sub
  20.  
Jun 16 '14 #1
2 1501
jimatqsi
1,271 Expert 1GB
Pranish01,
If you want help you're going to have to invest enough time into your post to tell us what you are trying to do and what the problem is. "It does not work" is not a clear description of what the problem is.

Jim
Jun 16 '14 #2
twinnyfo
3,653 Expert Mod 2GB
Pranish01,

A brief review of your strSearch and there might be a few minor edits:

Expand|Select|Wrap|Line Numbers
  1. strSearch = "SELECT * FROM tblSupplier " & _
  2.     "WHERE SupplierID Like '*" & strText & "*' " & _
  3.     "OR Company Like '*" & strText & "*' " & _
  4.     "OR FirstName Like "'*" & strText & "*' " & _
  5.     "OR LastName Like "'*" & strText & "*' " & _
  6.     "OR BusinessPhoneLike "'*" & strText & "*' " & _
  7.     "OR Address Like "'*" & strText & "*' " & _
  8.     "OR City Like "'*" & strText "*'" 
It appears you were using double quotes instead of single quotes and you were missing the ampersand (&) after your string variable.

This should get you headed in the right direction.
Jun 16 '14 #3

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

Similar topics

2
by: Paul Lee | last post by:
Hi all, I'm trying to use a Java written search code to traverse a DOM hierarchy. I'm mainy using code that I obtained from the Sun website. Basically, in main(), I have Element rootElement =...
6
by: Brian Miller | last post by:
I've been constructing an ASP.Net application using the 1.1 framework, and have been using Web Matrix for development purposes. Now that my application is near completion, I wanted to see if I can...
6
by: leonat | last post by:
I have an asp.net webform. When I view the page in the web browser, the html is returned but not any asp code, i.e., " <% ... %> ". This same code works in the "old" asp page BUT NOT in...
10
by: Fred | last post by:
OK, I can now successfully enter data into my MySQL database through my CGI web page. I can click a button and retrieve all the records, but I can not seem to get the search code to work. ...
2
by: dismantle | last post by:
Hi all, I need code help to perform a search code using access database i tried to search other threads but only saw this thread http://www.thescripts.com/forum/thread580180.html and its very...
4
by: dismantle | last post by:
Hi all, I need code help to perform a search code using access database i tried to search other threads but only saw this thread http://www.thescripts.com/forum/thread580180.html and its very...
2
by: karechio | last post by:
Hi Guys i am in dire need of a Search code in asp.net (VB) that searches a several tables in a database. I would appreciate any Help Offered. Thanks in Advance.
10
by: jonathan184 | last post by:
Hi I tried getting this to work through dreamweaver but it did not. So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me...
1
tpgames
by: tpgames | last post by:
I was trying to make my website accessible for those who need better colour contrast by allowing them to choose their css sheet that would be used all over my website. I got the code off the web...
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?
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.