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

I'm trying to create a search keyword in vba for a database in access. It doesnt work

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Private Sub Command24_Click()
  4. Dim strsearch As String
  5. Dim strText As String
  6. strText = Me.TxtSearch.Value
  7. strsearch = "SELECT * from Spare_Parts where ((PartName/Description like ""*" & strText & "*"") or (Manufacturer like ""*" & strText & "*""))"
  8. Me.RecordSource = strsearch
  9. End Sub
  10.  
  11. Private Sub Command25_Click()
  12. Dim strsearch As String
  13. strsearch = "SELECT * from Spare_Parts"
  14. Me.RecordSource = strsearch
  15. End Sub
  16.  
  17.  
  18.  
Attached Images
File Type: jpg vba.jpg (73.6 KB, 112 views)
Oct 13 '15 #1
2 950
Luk3r
300 256MB
In VBA you must use the % operator instead of the * operator when using LIKE
Oct 13 '15 #2
MikeTheBike
639 Expert 512MB
Hi

I think for Access objects i.e. forms, list and combo boxes etc. (and DAO recordsets I think) you use an * as the wild card. However, ADO recordset definitely use a %.

I never use DAO recorsets, so been caught out a few time pasting sql view strings in to ADO sql variable.


MTB
Oct 14 '15 #3

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

Similar topics

1
by: Ron L | last post by:
I am trying to setup a solution that will include a client which will access a database via remoting calls. I am hosting my remoting project in IIS, and am using Windows Integrated security. ...
1
by: Station Media | last post by:
Hi, here my problem, i use stored procedure in ACCESS database(latest version), and i would like to use this procedure but it doesnt work, do you know why ? Procedure: PARAMETERS MyField Text...
2
by: gaffar | last post by:
Hello Sir, i need the funtionality of Using ADOX to create a JET Database and tables in it and one to many relationship between the tables. Thanks for your help Gaffar.
7
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
hey, I have 2 threads, th and th2, both of them run a method. each of these 2 methods requires database access. sometimes I get an error, that database requires an open connection, and that...
0
Kosal
by: Kosal | last post by:
Hi Please help me to create AdRotator using Database Access in ASP.NET if everyone can because I don't know how to create table AdList in access and how to contect to access and get data from...
3
by: thread | last post by:
hi all, i'm trying to hide by database with this code: Application.CurrentDb.TableDefs(CurrentDb.TableDefs(i).Name).Properties("Attributes").Value = dbhiddenobject from some reason it doesnt...
4
by: suckyboy | last post by:
Hi... I have a small problem here. I did a database on my School computer with Access 2007. However, when I use the database on my Home computer with Access 2007 there. The search function doesnt...
1
by: sultan030281 | last post by:
hi! i'm beginner in access, please help me to create search button. i make form & in that form i give a text box. my wish, when I type a some name in the textbox, then I press that searchbutton,...
37
ashjones86
by: ashjones86 | last post by:
Hi All, So im looking for some help with access 2007 if at all possible. I am new to access as work has asked me to create a database, so the database side to it i have sorted i.e inputting data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.