Hi there
I have wrote a little script, that is used to search specific values that the User tips in. -
-
Private Sub cmdSearch_Click()
-
-
Dim LSQL As String
-
Dim LSearchString As String
-
-
If Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
-
MsgBox "You must enter a search string."
-
-
Else
-
-
LSearchString = txtSearchString
-
-
'Filter results based on search string
-
LSQL = "select Contacts.* , Work.* from Contacts, Work"
-
LSQL = LSQL & "where ((Contacts.ContactsID = Work.ContactsID) AND (FirstName LIKE '*" & LSearchString & "*'))"
-
-
Form_SearchForm_sub.RecordSource = LSQL
-
-
lblTitle.Caption = "Customer Details: Filtered by '" & LSearchString & "'"
-
-
'Clear search string
-
txtSearchString = ""
-
-
MsgBox "Results have been filtered. All Company Names containing " & LSearchString & "."
-
-
End If
-
Now I always receive "Syntax Error: FROM" when I try to use it with the command button.
Does anyone see the mistake? Also, if somebody knows how to add more "search values", such as LastName etc. I would be very happy about it. I though it should be possible just to add -
-
OR LastName LIKE '*" & LSearchString & "* OR CostCenter LIKE '*" & LSearchString & "*
-
Thanks a lot
8 2493 Stang02GT 1,208
Recognized Expert Top Contributor
Hello Alive,
Just trying to get a better understanding of what you want to do here. You are trying to have a search field in a text box that is executed by a command button?
Hello Alive,
Just trying to get a better understanding of what you want to do here. You are trying to have a search field in a text box that is executed by a command button?
Hello Stang02GT,
I am actually trying to develop a DB-"google"-Form. So, a User tips for example a firstname, and in a subform it will show all relevant data to that user. In my my script it has to get the information from table Contacts and Work.
Thanks
Stang02GT 1,208
Recognized Expert Top Contributor
Alright thank you, that gives me a better understanding of what you are trying to do.
Hi there
I have wrote a little script, that is used to search specific values that the User tips in. -
-
Private Sub cmdSearch_Click()
-
-
Dim LSQL As String
-
Dim LSearchString As String
-
-
If Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
-
MsgBox "You must enter a search string."
-
-
Else
-
-
LSearchString = txtSearchString
-
-
'Filter results based on search string
-
LSQL = "select Contacts.* , Work.* from Contacts, Work"
-
LSQL = LSQL & "where ((Contacts.ContactsID = Work.ContactsID) AND (FirstName LIKE '*" & LSearchString & "*'))"
-
-
Form_SearchForm_sub.RecordSource = LSQL
-
-
lblTitle.Caption = "Customer Details: Filtered by '" & LSearchString & "'"
-
-
'Clear search string
-
txtSearchString = ""
-
-
MsgBox "Results have been filtered. All Company Names containing " & LSearchString & "."
-
-
End If
-
Now I always receive "Syntax Error: FROM" when I try to use it with the command button.
Does anyone see the mistake? Also, if somebody knows how to add more "search values", such as LastName etc. I would be very happy about it. I though it should be possible just to add -
-
OR LastName LIKE '*" & LSearchString & "* OR CostCenter LIKE '*" & LSearchString & "*
-
Thanks a lot
You missed a SPACE between Work and where in the from clause, should be
LSQL = "select Contacts.* , Work.* from Contacts, Work "
although its more usual to us Contacts INNER JOIN Work ON etc.
I also think
OR LastName LIKE '*" & LSearchString & "* OR CostCenter LIKE '*" & LSearchString & "*
should work!
MTB
JKing 1,206
Recognized Expert Top Contributor
Good eye MTB!
The following string was missing closing single quotes. If it was a direct copy from your code and not just a string you typed on the fly for posting purposes, that would most likely be the source of your problem. Have a look I added them in below. -
OR LastName LIKE '*" & LSearchString & "*' OR CostCenter LIKE '*" & LSearchString & "*'"
-
You missed a SPACE between Work and where in the from clause, should be
LSQL = "select Contacts.* , Work.* from Contacts, Work "
although its more usual to us Contacts INNER JOIN Work ON etc.
I also think
OR LastName LIKE '*" & LSearchString & "* OR CostCenter LIKE '*" & LSearchString & "*
should work!
MTB
Thanks MTB that was the problem! Thanks for finding such a minuscule mistake. Thanks
Unfortunately, I am having another problem now. When I open the search form two Parameter Value Boxes appear. It asks me for the ContactsID and WorkID. How can I avoid that.
thanks
Thanks MTB that was the problem! Thanks for finding such a minuscule mistake. Thanks
Unfortunately, I am having another problem now. When I open the search form two Parameter Value Boxes appear. It asks me for the ContactsID and WorkID. How can I avoid that.
thanks
The problem disappeared...:-) ... I do not know what I did, that it vanished.
Thanks to all for the help
Please remember to provide a meaningful Title for any threads you start! This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions. It is difficult for the experts to answer questions when there is not enough details provided to understand the problem.
Please take the time to read the Posting Guidelines, paying particular attention to Give a clear title to your question. http://www.thescripts.com/forum/thread559246.html
Thank you and Welcome to TheScripts!!
Linq ;0)>
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Greg |
last post by:
I have a page that searches a database by a repairman's name and by a
date range. It pulls info by the repairman's name but pulls all info in
the database regardless of the date. Below is the code...
|
by: Spartanicus |
last post by:
I'm pondering what the various drawbacks are of the methods to code UI
elements who's function relies on javascript and css.
Currently on http://www.pan-europe.utvinternet.ie/ I use styled <a>...
|
by: Colleyville Alan |
last post by:
I have a incremental search box that has been working fine for a couple of
months but is now acting up. This search box is from the cd that comes with
Getz's book, so I did not write it and have...
|
by: Steph |
last post by:
Hi.
I'm very new to MS Access and have been presented with an Access database
of contacts by my employer.
I am trying to redesign the main form of the database so that a button
entitled...
|
by: higgy2005 |
last post by:
Hi there,
I would be very greatful if somebody could help me with my trouble
using VBA to code a button on a form. Basically what i want to happen
is on the click of the button i want it to...
|
by: saima khushbakht |
last post by:
hi
i need coding for find button using adodc control.the search should be by name.if we enter the name of employee then search button should search name from data base either it exists in batabase...
|
by: Mark |
last post by:
Hi All,
I am creating a music database for a friend and have run into a problem.
Within the ALBUM table, I wanted to store the ARTIST_ID rather than the
ARTIST_NAME. To do this, I intended to have...
|
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= |
last post by:
I am working with Visual C# window and in my application I need to use a
button ( NEXT) . The button should displays one panel with its objects each
time it clicked. I already developed the codes...
|
by: Ignacio Machin ( .NET/ C# MVP ) |
last post by:
On Apr 22, 2:51 pm, Tammy Nejadian
<TammyNejad...@discussions.microsoft.comwrote:
Do a search in the archives of this NG, look for "wizard" you will
find a lot of examples
|
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: 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,...
|
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: 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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |