473,507 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed with 'where syntax' in filter lookup

Hi can someone give me a hand with this please?
I'm trying to build a search filter that scans through a list of
client names in a database as you type into a text box and filters the
form records accordingly. The problem is my database structure is
making it difficult: I need the filter to first lookup the partially
inputted name in the clients table and then filter my invoices
according to the clientID from that table. Here's what I have so far
but it's not working:

Private Sub lookup_AfterUpdate()
DoCmd.ApplyFilter , "ClientID=(SELECT ClientID from clients WHERE
CompanyName LIKE '%" & lookup.Value & "%')"
End Sub

Thanks
Ciarán
Nov 16 '07 #1
4 2673
Hi -

First, the after update event does not fire after every keystroke as you are
typing in the textbox; it only fires after the control loses the focus.

Your "WHERE" should be "ClientID IN (Select .....)

Can I ask what the % signs are for?

Why do you want to refilter the form after every keystroke? How would you
know what records the form was going to display?

HTH

John
Cron wrote:
>Hi can someone give me a hand with this please?
I'm trying to build a search filter that scans through a list of
client names in a database as you type into a text box and filters the
form records accordingly. The problem is my database structure is
making it difficult: I need the filter to first lookup the partially
inputted name in the clients table and then filter my invoices
according to the clientID from that table. Here's what I have so far
but it's not working:

Private Sub lookup_AfterUpdate()
DoCmd.ApplyFilter , "ClientID=(SELECT ClientID from clients WHERE
CompanyName LIKE '%" & lookup.Value & "%')"
End Sub

Thanks
Ciarán
--
Message posted via http://www.accessmonster.com

Nov 16 '07 #2
On Nov 16, 5:50 pm, "J_Goddard via AccessMonster.com" <u37558@uwe>
wrote:
Hi -

First, the after update event does not fire after every keystroke as you are
typing in the textbox; it only fires after the control loses the focus.

Your "WHERE" should be "ClientID IN (Select .....)

Can I ask what the % signs are for?

Why do you want to refilter the form after every keystroke? How would you
know what records the form was going to display?

HTH

John

Cron wrote:
Hi can someone give me a hand with this please?
I'm trying to build a search filter that scans through a list of
client names in a database as you type into a text box and filters the
form records accordingly. The problem is my database structure is
making it difficult: I need the filter to first lookup the partially
inputted name in the clients table and then filter my invoices
according to the clientID from that table. Here's what I have so far
but it's not working:
Private Sub lookup_AfterUpdate()
DoCmd.ApplyFilter , "ClientID=(SELECT ClientID from clients WHERE
CompanyName LIKE '%" & lookup.Value & "%')"
End Sub
Thanks
Ciarán

--
Message posted viahttp://www.accessmonster.com
Hi John,
Thanks for the response - i actually only have the after update event
on for testing - I was planning to switch to on key up later.

I want it to filter the records in realtime so you only need enter the
first few letters of a client name to get what you're looking for.

The % sign is a wildcard character in SQL is it not?

Thanks again,
Ciarán
Nov 16 '07 #3
The SQL wildcard character is *, not %. I just tried select * where .. like
"%A%" - I didn't get an error, but I didn't get any data either!

Also, you have your wildcard on both ends of your search value, which means
it will find records with the string *anywhere* in the company name, not just
at the beginning.

HTH

John
Cron wrote:
>On Nov 16, 5:50 pm, "J_Goddard via AccessMonster.com" <u37558@uwe>
wrote:
>Hi -
[quoted text clipped - 31 lines]
>--
Message posted viahttp://www.accessmonster.com

Hi John,
Thanks for the response - i actually only have the after update event
on for testing - I was planning to switch to on key up later.

I want it to filter the records in realtime so you only need enter the
first few letters of a client name to get what you're looking for.

The % sign is a wildcard character in SQL is it not?

Thanks again,
Ciarán
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200711/1

Nov 16 '07 #4
On Nov 16, 7:42 pm, "J_Goddard via AccessMonster.com" <u37558@uwe>
wrote:
The SQL wildcard character is *, not %. I just tried select * where .. like
"%A%" - I didn't get an error, but I didn't get any data either!

Also, you have your wildcard on both ends of your search value, which means
it will find records with the string *anywhere* in the company name, not just
at the beginning.

HTH

John

Cron wrote:
On Nov 16, 5:50 pm, "J_Goddard via AccessMonster.com" <u37558@uwe>
wrote:
Hi -
[quoted text clipped - 31 lines]
--
Message posted viahttp://www.accessmonster.com
Hi John,
Thanks for the response - i actually only have the after update event
on for testing - I was planning to switch to on key up later.
I want it to filter the records in realtime so you only need enter the
first few letters of a client name to get what you're looking for.
The % sign is a wildcard character in SQL is it not?
Thanks again,
Ciarán

--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...

Thanks John - i figured that out the hard way too. Apparantly, Access
uses the * character while most other SQL clients use the %.
My final working syntax if anyone wants it is:

Private Sub lookup_KeyUp(KeyCode As Integer, Shift As Integer)
DoCmd.ApplyFilter , "ClientID IN (SELECT ClientID from clients WHERE
CompanyName LIKE '" & lookup.Value & "*')"
End Sub
Nov 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
44508
by: mheydman | last post by:
I apologize if this has been asked before- I searched google but could not find a concrete answer. I recently inherited a database whose t-sql code is written in a format that I find difficult...
28
3253
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
4
1818
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
3
1834
by: ATS | last post by:
I'm trying to set up a slide show on a web page using Javascript. Here is the code I have so far: <script language="javascript"> alert("**in test area 1"); slides = new Array(); slides =...
5
1197
by: chris.withers | last post by:
Hi all, I'm attempting to do something like the following SQL query: SELECT * FROM `users` WHERE idusers != 3 | 2; such as: = "idusers <> 3OR 2";
0
5518
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
1541
by: Strasser | last post by:
In a nested subform in datasheet view, an interviewer of homeless people picks a descriptive CATEGORY from 20 descriptive categories. The 20 categories are displayed via a combo box. (Categories...
14
18251
by: mjvm | last post by:
HI, I have had a search for the answer to this question, but I can't transfer what I am reading to my database. I don't know enough about the language required, but have been able to get my...
3
2112
by: luciegiles | last post by:
I'd like to start off with an apology - I posted a question on a similar matter sometime ago and didn't respond to those who took the time to answer my question. At the time i gave up but have used...
0
7109
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...
0
7313
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,...
0
7372
jinu1996
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...
0
7481
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
5619
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,...
1
5039
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
4702
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
3190
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
3179
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.