I have created a query that will pull information from our database for the operators. This query will pull in on average 50,000 records. The operators need to refine the search results. I have used the following in the criteria section of the query for the operators to refine the search [Enter the Clients Name:]. However, the operators do not always remember how the clients name appears in the DB and we get several failed queries. To correct this, I created a form with a pick list and a command button. The operator will select the clients name and run the query from the command button. In the query I replaced [Enter the Clients Name:] with the following; forms!form1!tex t1. The selected value in text1 from the form gets passed to the query and the results are returned. This will shrink the results to maybe 2000 records. However, we still need to refine the search even further. One of the fields in the query stores branch numbers. The field in the table is a text field. The operator needs to exclude a certain group of branches from the results. On the form I created a text box for them to enter the branches to exclude. I have them entering
Not In ("59","99","78" ). When this gets passed to the query, Access puts single ' around the text and the query returns 0 records. If the Not In statement is placed directly in the query criteria field we get the proper results. How can I pass this type of information from a form to a query so we can refine the results?
10 6232 NeoPa 32,579
Recognized Expert Moderator MVP
If you tell us how you're building your SQL (or query) and how you're applying the filter we can help you with a modified version.
Your question doesn't make it clear what you're doing exactly.
If you tell us how you're building your SQL (or query) and how you're applying the filter we can help you with a modified version.
Your question doesn't make it clear what you're doing exactly.
Its a simple query that is based on one table that contains 15 columns of data. (14 columns are text based and 1 is a date). I am retrieving all 15 columns of data. I am currently filtering on two columns (Date and Name) and would like to add a third (Branch #). Branch numbers are from 00 - 99 and again stored as text
On the form (titled - Activity), the operator will enter a date in a text box (titled Date). In a separate text box the operator will enter the client name. (titled Name). In the query, date column criteria has the following -
forms!activity! date. The name column has the following - forms!activity! name.
When the operator launches the query from the form, it passes the date and name to the query and we get the results. I would like to add a filter for the branch number. We need to exclude certain branch numbers from the results to get at the data we are looking for.
I have tried the following with no luck. I created a new text box on the form (Titled Branch). In the query, branch column criteria has the following -
forms!activity! branch. I have tried passing in the following to filter on the branch number (keep in mind the branch number column is stored as text)
Not In ("59","99")
<> "59" and <> "99"
If either of the above filters are used from the form, we get 0 items returned.
I found that Access places single ' around the filters above and thats why I believe we are getting 0 records returned. If I use the filters above directly in the query criteria field we get the correct results. Is there another way to filter the branch number that will return results?
Just wondering... Why is a number being stored as text? You may want to try putting #59# around the numbers. And also might want to try putting a parameter for the numbers being calculated as text and not numbers.
Just a thought.
here is the sql for what the parameter would look like:
PARAMETERS forms!activity! branch Text ( 255 );
SELECT (your select clause)
FROM (etc..)
WHERE (etc...)
Its a simple query that is based on one table that contains 15 columns of data. (14 columns are text based and 1 is a date). I am retrieving all 15 columns of data. I am currently filtering on two columns (Date and Name) and would like to add a third (Branch #). Branch numbers are from 00 - 99 and again stored as text
On the form (titled - Activity), the operator will enter a date in a text box (titled Date). In a separate text box the operator will enter the client name. (titled Name). In the query, date column criteria has the following -
forms!activity! date. The name column has the following - forms!activity! name.
When the operator launches the query from the form, it passes the date and name to the query and we get the results. I would like to add a filter for the branch number. We need to exclude certain branch numbers from the results to get at the data we are looking for.
I have tried the following with no luck. I created a new text box on the form (Titled Branch). In the query, branch column criteria has the following -
forms!activity! branch. I have tried passing in the following to filter on the branch number (keep in mind the branch number column is stored as text)
Not In ("59","99")
<> "59" and <> "99"
If either of the above filters are used from the form, we get 0 items returned.
I found that Access places single ' around the filters above and thats why I believe we are getting 0 records returned. If I use the filters above directly in the query criteria field we get the correct results. Is there another way to filter the branch number that will return results?
Just wondering... Why is a number being stored as text? You may want to try putting #59# around the numbers. And also might want to try putting a parameter for the numbers being calculated as text and not numbers.
Just a thought.
here is the sql for what the parameter would look like:
PARAMETERS forms!activity! branch Text ( 255 );
SELECT (your select clause)
FROM (etc..)
WHERE (etc...)
The branch number is being stored as text because that is how is passed to us from the customer.
Thx for the help. I tried the # around the numbers and it did not work. I am not sure how to apply the other suggestion. Where would this statement be located? On the form or in the sql for the query?
Yes it is found in the SQL of the query.. If you right click up where the tables for the query are shown, you can select 'parameters' and set the parameter and the type.
The branch number is being stored as text because that is how is passed to us from the customer.
Thx for the help. I tried the # around the numbers and it did not work. I am not sure how to apply the other suggestion. Where would this statement be located? On the form or in the sql for the query?
Yes it is found in the SQL of the query.. If you right click up where the tables for the query are shown, you can select 'parameters' and set the parameter and the type.
I added the parameter statement and still get zero records. What should we be entering in the text box on the form that will be passed to the query?
NeoPa 32,579
Recognized Expert Moderator MVP
When in a designed query (QueryDef) you enter a reference to a field on a form for your criteria, it simply compares the data with the value in the form's field.
NB It doesn't provide a means of changing the query generally.
If you want to change the actual SQL (Seems necessary here) it gets more complicated.
You need to either :
1. Copy your existing query to another (temp) name then set the .SQL property after modifying a string with SQL grabbed initially from the query.
2. Create a new temporary query and set the SQL as in 1 above.
If no-one comes up with a simpler solution, then I'll dig up details of the basics of this approach for you.
When in a designed query (QueryDef) you enter a reference to a field on a form for your criteria, it simply compares the data with the value in the form's field.
NB It doesn't provide a means of changing the query generally.
If you want to change the actual SQL (Seems necessary here) it gets more complicated.
You need to either :
1. Copy your existing query to another (temp) name then set the .SQL property after modifying a string with SQL grabbed initially from the query.
2. Create a new temporary query and set the SQL as in 1 above.
If no-one comes up with a simpler solution, then I'll dig up details of the basics of this approach for you.
FYI, I am not sure this will help but here is the query I am currently using. On the form, the operator can only enter 1 branch number at a time. This restricts the info the operators get. They need to be able to see multiple branch at the same time. I figure the exclude option would be better since we only need to exclude three or four versus including 30 to 50.
SELECT DATE, CLIENT_NAME, BRANCH, ADDRESS, CITY, STATE, ZIP, COUNTRY, TRACE, RESEARCH, OPERATOR,
OPID, ORDERCODE, DESC1, DESC2, DESC3
FROM PENDING_ORDERS
WHERE DATE = FORMS!ACTIVITY! DATE
AND CLIENT_NAME = FORMS!ACTIVITY! NAME
AND BRANCH = FORMS!ACTIVITY! BRANCH;
NeoPa 32,579
Recognized Expert Moderator MVP
In your command Button code (OnClick event)
You need some code that will modify your SQL.
Then you need to have a temp query to put the new SQL in.
If you put it in the original query then this will be changed for next time (Unpredictable) .
Something along the lines of - Dim strSQL As String, strWhere As String
-
Dim intWhere As Integer
-
-
strSQL = CurrentDB.QueryDefs("YourQueryName").SQL
-
intWhere = InStr(1, strSQL, "WHERE ")
-
strWhere = "WHERE (([Date]=" & FORMS!ACTIVITY!DATE & ") AND " & _
-
"([BRANCH]" & FORMS!ACTIVITY!BRANCH & "))"
-
strSQL = Left(strSQL,intWhere) & strWhere
-
CurrentDB.QueryDefs("TempQueryName").SQL = strSQL
You'll have to fill in the gaps. I haven't time to do it all for you, but this is the idea.
Have fun.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve |
last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's
criteria is set ats:
Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the
selections are 30, 60 and 90. The default is set at 30.
Question1: When the form opens, there are no records displayed although there
are many records that fit the criteria of 30. If I put a button on the form to
do a requery and press the button, all the records...
|
by: neptune |
last post by:
I built a form to access a query with a 2 field primary key. It
should use 2 controls to find the unique record and display the other
field values on the form. In the criteria section of the query, I set
the 2 primary key values equal to the 2 control values on my form.
When I input a value to these 2 controls the query finds the correct
record, so I know my query with the criteria works.
My problem is trying to get the output values...
|
by: Don Seckler |
last post by:
I have an update query that runs when a report closes. I have several
reports that will need to run the update query with diferent criteria.
I'd like to simply make the criteria change in the report vba instead
of making different queries.
Here's my query sql:
UPDATE Draw SET Draw.Billed = Yes
WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson"));
|
by: JM |
last post by:
Hello,
Using Access 2000 queries, you can reference(pass) form values directly
using syntax like Forms!frmPaint!txtColor. I want to do a pass
through query to SQL Server 2000, but I don't know how to pass the form
values to SQL server without resorting to VB code. These canned
queries populate other elements of the form, and that's another reason
I don't want to write additional code. These queries were originally
set up merely...
|
by: starace |
last post by:
I have designed a form that has 5 different list boxes where the
selections within each are used as criteria in building a dynamic
query. Some boxes are set for multiple selections but these list boxes
do not necessarily need to have a selection made to be used in the
dynamic query.
In essence the form can have selections made in all or none of its list
boxes to form the dynamic query
I am looking to get some feedback in reference to...
| |
by: dskillingstad |
last post by:
I'd appreciate any help I can get. I'm not sure what I'm doing wrong,
but....
I've searched these groups for some solutions but no luck.
I have an unbound form (frmSearch), with several unbound text boxes on
it and a command button bound to a macro which fires off a parameter
query based on the criteria/string that the user types into the text
boxes on frmSearch. My goal is to create a search form where the user
can search by any of...
|
by: Zlatko Matiæ |
last post by:
Hi everybody!
Recently I was struggling with client/server issues in MS Access/PostgreSQL
combination.
Although Access is intuitive and easy to use desktop database solution, many
problems appear when someone is trying to use it as front-end for real
server database systems such as PostgreSQL or MySQL.
One of these problems is regarding pass-through queries and parameters.
I wanted to have all the code on client, while executing it on...
|
by: Bob Alston |
last post by:
If you have an access form with record source being a straightforward
query and where clause in the form definition, will the query be sent to
the back end jet/Access database and executed there, withonly the
record(s) meeting the criteria being returned to the front end?
Is JetShowPlan a good tool to see that this is working?
Bob
|
by: Trevor2007 |
last post by:
I have a query that setting date from and date to from form values works:
>=!! And <=!!
but now I am trying to add another peramiter to pass in adition to above and now it doesn't work, I get a blank table when I run it and when i run the criteria just for State by
Forms!! I get a blank form as well,
what I'm trying to do is is set criteria of query with
>=!! And <=!! And !!
and when i run it I get a blank table
...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |