473,771 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ 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:Applicatio ns". 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 3666
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,573 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,573 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
3207
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
12400
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
8674
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
3481
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: Object.Variables.Customers.CusomerID = .... This works great and is similar in structure as for example the Docmd. or me. structure. Now I created a search form which can be opened from many forms, it consist of only a listbox. The listbox is filled at startup....
11
3565
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 but x.gettype returns 'string', so it knows it contains a string. If I want to create a variable "y" as the same type that variable x contains how would I do that without having to iterate thru every possible
1
1562
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 the database according to my data in formA. However, I want to reuse the result search in formA by a modifying data form <--I call ths as formB The question is : How can I share the variable such as recordset, search result.....in 2 different...
5
5708
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 through to the DB but most cannot and I can't work it out. The error people receive when trying to log onto the DB is 'Object variable or With block variable not set'. I don't understand how some machines will connect but most won't. I didn't create the...
2
1500
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 the read() method. The page in question is a string matching search page (its a photo site and the photos have associated tags) that may return multiple results. I wish to display the first picture match and its details and then have a button that...
9
1916
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 the name in my string variable, then I know I have the correct control and can proceed to change the property. However all that searching seems like overkill. Does anyone know of a way to directly access the control if it's name is in a string...
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9911
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.