Dear Sir
I've a table called "Table3" with primary key and questions
--------------------
P.K | Question
--------------------
I'd like to search in the questions field using multiple keywords that are not related,
i.e., "population, crowd, ...etc".
My form contains:Text Box(txtDescription), search button(cmdMultiSearch).
I read the post "Search by Multiple Keywords "
and in similar fashon I modified the code to: - Private Sub cmdMultiSearch_Click()
-
Dim intIdx As Integer
-
Dim strWork As String, strSearch As String
-
Dim GCriteria As String 'Unnecessary if Dimensioned elsewhere
-
-
If Nz(txtDescription, "") = "" Then
-
MsgBox "You must enter a search string."
-
Else
-
'Generate search criteria
-
GCriteria = ""
-
strSearch = txtDescription 'txtSearchString
-
Do
-
intIdx = InStr(1, strSearch, ",")
-
If intIdx > 0 Then
-
strWork = Trim(Left(strSearch, intIdx - 1))
-
strSearch = Mid(strSearch, intIdx + 1)
-
Else
-
strWork = Trim(strSearch)
-
strSearch = ""
-
End If
-
GCriteria = GCriteria & " AND ([" & Question & _
-
"] Like '*" & strWork & "*')"
-
-
Loop While strSearch > ""
-
GCriteria = Mid(GCriteria, 6)
-
-
With Me 'Assuming Me = Form_frmReferenceBooks otherwise With Form_frmReferenceBooks
-
'Filter frmReferenceBooks based on search criteria
-
.RecordSource = "SELECT * " & _
-
"FROM Table3 " & _
-
"WHERE " & GCriteria
-
.Caption = "Table3 (" & _
-
Question & _
-
" contains '" & _
-
txtSearchString & "')"
-
End With
-
MsgBox "Results have been filtered."
-
End If
-
End Sub
I get the message"Results have been filtered.".
My question is how to get the search result in a table???
Thanks for help.
Hi.
I'd be happy to help further but a more detailed answer requires a much more detailed question.
For instance, which table would you like the data output to? Have you considered how you will use this table? If it's a multi-user situation this is much more involved.
In very basic terms you need SQL of the format : - INSERT INTO [DestinationTable]
-
( [Field1]
-
, [Field2] )
-
SELECT [Field1]
-
, [Field2]
-
FROM [SourceTable]
-
WHERE ({YourCriteria})
9 4368 NeoPa 32,556
Expert Mod 16PB
To get the results into a table you need to execute a query very similar to what you have already, but as an append (INSERT INTO) query.
Sorry But how to do that because I am new to Access?
NeoPa 32,556
Expert Mod 16PB
Hi.
I'd be happy to help further but a more detailed answer requires a much more detailed question.
For instance, which table would you like the data output to? Have you considered how you will use this table? If it's a multi-user situation this is much more involved.
In very basic terms you need SQL of the format : - INSERT INTO [DestinationTable]
-
( [Field1]
-
, [Field2] )
-
SELECT [Field1]
-
, [Field2]
-
FROM [SourceTable]
-
WHERE ({YourCriteria})
Thanks Sir;
It is not multi-user, I did exactly what you advised me but every run I get the whole DB in the DestinationTable.
So is the query syntax wrong or what?
Thanks in advance.
NeoPa 32,556
Expert Mod 16PB
From what you say it sounds like the {Criteria} itself is wrong. It would be a good idea, at this stage, to post your SQL (<>VBA) code for us to look over for you.
Sorry I mean my SQL statement.
My SQL is: - SELECT Table3.Question, Table3.ID
-
FROM Table3
-
WHERE (((Table3.Question) Like "*"& [Forms]![Main]![txtDescription] & "[!a-z]*"));
but I wand to search for multiple words from the text box and get the result in a table as I click the command button.
Thanks
NeoPa 32,556
Expert Mod 16PB
SQL / Query - Both are understood to be the same. I was simply suggesting you avoid posting the VBA code that creates your SQL as many members (unfortunately) do in circumstances where that is not appropriate. You have posted the SQL perfectly (Use the [CODE] tags for preference but the contents are fine).
Back to your questions :
The first problem is that there are two fundamental questions in the question. This is not how things are supposed to work. One question per thread is the rule.
However, in this case there is one fairly simple one which we will get out of the way and allow the thread to remain about matching multiple keywords.
Changing a simple SELECT query into an append (INSERT INTO) query is done by adding the INSERT INTO clause at the front. As illustrated in my (amended) post #4. The INSERT INTO clause should include a list of the fields to take the data within parentheses.
As for the criteria used to handle multiple words, that is much more of a question and will require us to update the SQL code in VBA and execute the amended SQL code from the VBA string. Before we get that far though, we need to find out why what you have isn't working as expected.
First try for me to update the SQL so that each ampersand (&) character is surrounded by at least one space. Test the results with a known value in txtDescription and report back the results and the value used.
Thanks Sir, it works fine.
NeoPa 32,556
Expert Mod 16PB
Good to hear :-)
Was it the ampersand?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Rizyak |
last post by:
********************
alt.php.sql,comp
databases.ms-sqlserver
microsoft.public.sqlserver.programming
***********************************
Why doesn't this work:
SELECT *
FROM 'Events'
|
by: Abbey Krystowiak |
last post by:
Does anyone know if I can have a field in a row where I can add two
lines of info without adding a whole new line?
and then there would be a drop down menu?
*** Sent via Developersdex...
|
by: JP SIngh |
last post by:
Hi All
This is a complicated one, not for the faint hearted :) :) :)
Please help if you can how to achieve this search.
We have a freetext search entry box to allow users to search the...
|
by: Sheau Wei |
last post by:
i want to make a search engine for may database. i want to make the radio option at the search engine, but how to handle the search at the radio and the text field
|
by: Richard S |
last post by:
CODE: ASP.NET with C#
DATABASE: ACCES
alright, im having a problem, probably a small thing, but i cant figure out, nor find it in any other post, or on the internet realy (probably cuz i wouldnt...
|
by: sachin pathare |
last post by:
hi all,
plz help me out, is there any function or wayout to find multiple keywords from a perticular string stored in the database.
e.g
String stored in database: "hi my name is sachin"...
|
by: mforema |
last post by:
Hi Everyone,
I want to search records by typing in multiple keywords. I currently have a search form. It has a combo box, text box, Search command button, and a subform. The combo box lists the...
|
by: martin DH |
last post by:
Hello all,
I'm thinking this is a simple question...
I have a table (tblData) that includes a large-capacity text field (255 characters). I would like to write a query that pulls records that...
|
by: dugald.morrow |
last post by:
I have some javascript that updates the text in a text field after
certain actions take place such as clicking a checkbox. The javascript
works fine in Safari and Firefox, but in IE, the text in...
|
by: John Kotuby |
last post by:
Hi all,
Maybe this belongs in the Full Text group but I am writing an ASP.NET
application with a SQL Server 2005 backend, so I am posing the question
here.
I have been using fulltext search...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
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: 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,...
|
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...
|
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: 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...
| |