473,465 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Variable search in Access

23 New Member
Hi, I need some help, I would be eternally greatful for any kind person out there to give me any advice.

I've created a database for the youth centre. It stores applications for funding. I have the table "tbl:Applications". And in that table there is a Notes field. I want to be able to do a search to bring up a list of all records containing certain words in the notes field. The thing is, I'm not sure on how to do this. I'm pretty sure the solution is either in an SQL query, or doing SQL from VBA.

I can get it to search for a specified word - for example if I want to search for all records containing the word "music", I have this SQL:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM [Tbl:Applications]
  3. WHERE ((([Tbl:Applications].Application_Name) Like "*music*"));
And that works fine. But I want it to search for a variable. One time I might want it to search for "music", next I might want it to search for "art", or I might want it to search for "Young Mums Equipment" (so more than one word). I just want to know how to achieve this. In an access query you can have [insert text] which will bring up an input box labelled "insert text" and what you tye in that it will search for, BUT it will only search for exact matches, unless you type asterisks around your search text. Is there any way to automatically put asterisks around the search criteria in the SQL code to make it do a containing text search, or is there something to do in VBA to do this? I need some help and I'm not an expert, but I need to get this working.
Feb 9 '07 #1
6 3644
Rabbit
12,516 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM [Tbl:Applications]
  3. WHERE ((([Tbl:Applications].Application_Name) Like "*" & [Search String] & "*"));
  4.  
This will bring up an input box asking the user to define [Search String].
Feb 9 '07 #2
Robertf987
23 New Member
Rabbit, I only have one thing to say.... Will you marry me? Thank you! So simple. I had tried over and over and over again along those lines you showed me, but never got it quite right. I'd searched all over the net but couldn't find anything, I muddled around with code and actually got very, very close to what you put, but was getting muddled with apostrophes and quotation marks.

Thank you again for your help, and so quickly, you're a life saver! I give you this cookie in thanks *passes cookie*
Feb 9 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
You're welcome.
Feb 9 '07 #4
NeoPa
32,556 Recognized Expert Moderator MVP
Rabbit, I only have one thing to say.... Will you marry me?
So which of you is the Groom and which the Bride? I hope you know - it could get confusing :D
You may find this link (Tutorials on Access and VBA) helpful as there are a number of helpful threads on some of the basics of Access.
I would just add that in SQL it is a good idea to get into the habit of using single-quotes (') for strings. This is explained further in one of the links found in the Tutorials thread.
Feb 11 '07 #5
Robertf987
23 New Member
Thanks NeoPa, I'll check out the link. Unfortunatley I don't think the marriage will go ahead. You see, I'm quite, quite insane. I've been learning most things in computing basically as and when I need them. I've made a fair few databases, both at school for projects and some actually in use, so I'm not exactly a newbie at all this. It just happens I never actually learned SQL at school, and I got a tad stuck. The database is now all complete and working, has nice lovley print functions to automatically merge stuff into word and print it all, (not exactly a mail merge, slightly different), search functions.... and it all looks very professional and pretty (I might get stuck with the programming, but making things look pretty and professional on the computer is something I do well!)
So thanks again for everybody's help. I shall stop now before I make myself look like a crazy person.
P.S. no cookies left.
Feb 12 '07 #6
NeoPa
32,556 Recognized Expert Moderator MVP
If you want to blend in here - just act crazy :D
Feb 12 '07 #7

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

Similar topics

1
by: Dennis Westermann | last post by:
I have the following problem XML-File: <SEARCH> <TAG>'x' or 'y'</TAG> </SEARCH> <CHARLIST> <CHAR>a</CHAR> <CHAR>x</CHAR>
3
by: Enoch Chan | last post by:
I would like to set a Session variable to a value. In Vbscript it should be Session("ZoomValue")=500 How can I set this session variable by using Javascript? Thanks
166
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
2
by: Remco Groot Beumer | last post by:
Hello, I created a program in which I use modules and classmodules for setting my variables. For example when I need to set the customerID in a variable I use something like: ...
11
by: JohnR | last post by:
I'm trying to find a way to create a variable of a given type at runtime where I won't know the type until it actually executes. For example, dim x as object = "hi" x is declared as an object...
1
by: Kwok | last post by:
In MS Access 2000, I created several forms because I am not familiar in GUI setting. As I created the forms, such that I can input some data <---I call this as form A Then I search the result from...
5
by: mekon | last post by:
Hi All, I'm hoping someone out there can give me a hand with this problem I've got. I have an Access DB that people connect to using Access RT 2000. There are some machines that can connect...
2
by: bcshaw | last post by:
Hey all I have a vb.net/asp.net dynamic website connected to an access database using a oledb connection. I use a datareader to retrieve the results of a query and iterate through the results using...
9
by: JohnR | last post by:
I have the name of a control in a string variable and I want to change one of the controls properties. Right now I recursively scan all the controls on the form until I get one whose name matches...
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
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,...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.