473,498 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query Improvement

26 New Member
Background-
Front end: MS Access 2010/VBA
Back end: MS SQL Server 2008
Me: Scale 1 - 10 (10 being high) Access: 5 SQL: 4

I have a form/sub form combo that solicits the visitor for their company name (see attached).
After they press the "Look Up" button the query will list the company along with the company's
location. The Link Master Fields and Link Child Fields causes the query to work.

The client has asked if partial name could be entered instead the full company's name and list all companies. For example
the visitor instead of entering National Fabrication Company could enter National. They would
get something like this:

Active Y National Bearings Columbus
Active Y National Fabrication Company Cincinnati
Active Y National Fabrication Company St. Louis

Thanks in advanced for you help.
Attached Files
File Type: doc Doc1.doc (73.5 KB, 148 views)
Nov 21 '14 #1
7 977
Seth Schrock
2,965 Recognized Expert Specialist
Probably the easiest method would be to have the list of possible companies be listed in a combobox that sorts them by name. The combobox has built in the lookup as you type.

A more complicated, but possibly more like what you are looking for, would be to have your lookup form have a textbox in the header that uses its On_Change event to constantly update the form's filter. The form would be viewed in Continuous form view. You could then double-click the company that you want and write the code so that the record you select gets entered as the company that the visitor is from.
Nov 21 '14 #2
jforbes
1,107 Recognized Expert Top Contributor
I use this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdApplyFilter_Click()
  2.     Dim sSearch As String
  3.     sSearch = Nz(Me.txtSearch.Value, "")
  4.     If Len(sSearch) > 0 Then
  5.         Me.CompanySub.Form.Filter = "Company LIKE '*" & sSearch & "*'"
  6.         Me.CompanySub.Form.FilterOn = True
  7.     Else
  8.         Me!CompanySub.Form.FilterOn = False
  9.     End If
  10. End Sub
When doing this, there is no link between the Main and SubForm

It's tied to a button just because it makes people more comfortable, but you could easily attach it to the OnChange like Seth is talking about.
Nov 21 '14 #3
CLSkcab
26 New Member
What is me.companysub.form referring to?
Nov 21 '14 #4
jforbes
1,107 Recognized Expert Top Contributor
The Me.CompanySub.Form is getting a reference to the actual Form Object being displayed by the SubForm Control. So in this case it is the Form that is to be Filtered. You would need to replace CompanySub with the name of the Control for your SubForm. This might help or confuse you http://access.mvps.org/access/forms/frm0031.htm, it explains how to refer to MainForms and SubForms.

I just copied and pasted something I had and my SubForm Control was named CompanySub.
Nov 21 '14 #5
CLSkcab
26 New Member
Here is my code. I put in the "Look Up" button.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdNext_Click()
  2. Dim sSearch As String
  3.     sSearch = Nz(Me.fCompany.Value, "")
  4.     If Len(sSearch) > 0 Then
  5.         Me.[signin subform].Form.Filter = "Company LIKE '*" & sSearch & "*'"
  6.         Me.[signin subform].Form.FilterOn = True
  7.     Else
  8.        Me.[signin subform].Form.FilterOn = False
  9.     End If
  10. End Sub
  11.  
It does not find anything.
Nov 24 '14 #6
jforbes
1,107 Recognized Expert Top Contributor
Hmmm... Here is a couple things to check/try:

Make sure your MainForm and SubForm do not have any linking as you will be taking over that functionality with the filtering. When you open the MainForm the SubForm should be showing you all it's records. (You can change that later if you would rather it not show any records to start with)

Hard code something for your sSearch variable that you know will return a recordset with records and see what it accomplishes.
Nov 24 '14 #7
CLSkcab
26 New Member
Got it to work. Had to remove the Link Master Fields and Link Child Fields values.
Nov 24 '14 #8

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

Similar topics

5
2226
by: Adam i Agnieszka Gasiorowski FNORD | last post by:
I need help width formulating the most effective (in terms of processing time) SQL query to count all the "new" documents in the repository, where "new" is defined as "from 00:00:01 up to...
3
3020
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
4
3709
by: Jorge | last post by:
Hi, I wonder if you could shed some light into this. I have the following table. Id, ContentId, VersionDate, ContentXml There are several ContentIds in the table. SELECT * FROM ...
3
2241
by: Paul Janssen | last post by:
Hello! Can anyone help me out with the following situation: (a) a single query with 550 id's in the IN-clause resulting into 800+ seconds; (b) 550 queries with a single id in the IN-clause...
5
1666
by: Bob Stearns | last post by:
When I run the following query with the two sections commented out, the response time is between 1 an 2 seconds; with the first indicated section enabled, the response goes up to 15 seconds even...
9
1486
by: Steve Jorgensen | last post by:
First, an example - today, I wanted to print out the parameter values in a querydef object at a break point in the code for subsequent manual debugging of the query. In the past, I would have had...
15
5623
by: Rolan | last post by:
There must be a way to enhance the performance of a query, or find a plausible workaround, but I seem to be hitting a wall. I have tried a few tweaks, however, there has been no improvement. ...
5
3497
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
10
2159
by: Raj | last post by:
I have an MDC index on Big_A.Dt column. The following query always goes for a table scan. SELECT Key, Cd, Dt, SUM(Big_A ) FROM ( SELECT Big_A.Key , small_3.Cd,
12
3373
by: Yash | last post by:
My SQL query is like: SELECT ..... FROM tblCLAIM C INNER join tblXXX .... INNER join tblYYY ....(5 more joins) WHERE C.created_date between @start_date and @end_date AND...
0
7125
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
7165
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,...
1
6887
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...
0
7379
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...
1
4910
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
3093
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
1419
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
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...

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.