473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Query Improvement

26
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, 147 views)
Nov 21 '14 #1

✓ answered by jforbes

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.

7 975
Seth Schrock
2,965 Expert 2GB
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 Expert 1GB
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
What is me.companysub.form referring to?
Nov 21 '14 #4
jforbes
1,107 Expert 1GB
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
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 Expert 1GB
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
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
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
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
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
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
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
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
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
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
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
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.