473,480 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Basing a query of a text field and combo box in a form

3 New Member
Hi there,

I have a form that has a text field and a combo box (address number and street name) that I'd like the user to use as a way to query all records from that particular combination. I've create the text box and combo box and named them txEAN and txESN. The form is names CustomerServiceCalls. In the criteria of the query, I've entered the following code for the address number and street name fields using the expression builder:

[Forms]![CustomerServiceCalls]![txEAN]

[Forms]![CustomerServiceCalls]![txESN]

When I enter an address number and a street name in the form and press the "run query" button, I get a popup that asks me to enter the parameter values for the address numbers and street names. It won't seem to run the criteria to pull that information from the form.

Any thoughts?
Jul 18 '16 #1
4 1018
zmbd
5,501 Recognized Expert Moderator Expert
You may have something mis-spelled.
Open the query editor
Switch to SQL view
Copy and paste the text there into a post here....
Please format the SQL script using the [CODE/] format in the tool bar.

You might find this an interesting read while you wait for us to take a look at what you post: Access Tutorial 10: Parameter Queries (PDF)
Section 10.3.3 starts showing how to reference the form in the parameters.
Jul 20 '16 #2
JBrinovcar
3 New Member
Expand|Select|Wrap|Line Numbers
  1. SELECT CustomerServiceCalls.[Customer First Name], CustomerServiceCalls.[Customer Last Name], CustomerServiceCalls.[Address Number], CustomerServiceCalls.[Street Name], CustomerServiceCalls.[Phone Number], CustomerServiceCalls.[Date of Call], CustomerServiceCalls.[Time of Call], CustomerServiceCalls.[Description of Complaint/Issue], CustomerServiceCalls.[Crew Responding], CustomerServiceCalls.[Supervisor Notified?], CustomerServiceCalls.[Date of Notification], CustomerServiceCalls.[Time of Notification], CustomerServiceCalls.[Action Taken], CustomerServiceCalls.[Additional Information Attached to Hardcopy], CustomerServiceCalls.Pressure, CustomerServiceCalls.[Flow Rate], CustomerServiceCalls.[Further Action Required?], CustomerServiceCalls.[Description of Further Action], CustomerServiceCalls.[Additional Information Attached to Hardcopy_1], CustomerServiceCalls.[Complaint Resolved?], CustomerServiceCalls.[Date of Resolution], CustomerServiceCalls.[Date of Resolution], CustomerServiceCalls.[Time of Resolution]
  2. FROM CustomerServiceCalls
  3. WHERE (((CustomerServiceCalls.[Address Number])=Forms!CustomerServiceCalls!txEAN) And ((CustomerServiceCalls.[Street Name])=Forms!CustomerServiceCalls!txESN));
Jul 22 '16 #3
zmbd
5,501 Recognized Expert Moderator Expert
+ From your post I gussed that the form was open. What I didn't ask, and I should have just to verify, is if the form is open when the code or query is executed. If you close the form then the query will choke. The form may be hidden; however, it must be open.

++Double check the spelling here against your control name in the WHERE clause of the SQL:
"txEAN" ... should this be "txtEAN"

A few other things that strike me:
+ Your form name is CustomerServiceCalls
And your table name is CustomerServiceCalls
This may be confusing the SQL interpreter because of the way the SQL is written - shouldn't however, stranger things have happened (more about this follows).

+ In the query you have things such as
CustomerServiceCalls.[Customer First Name]
and
FROM CustomerServiceCalls

Ideally, IMHO, these should be fully qualified with square brackets so that you have:
[CustomerServiceCalls].[Customer First Name]
and
FROM [CustomerServiceCalls]

This includes the conditional in the WHERE clause of the SQL with a special notice that I do NOT have the square braces around the Forms part of the statement because this refers to an Access Object collection
CustomerServiceCalls.[Address Number])=Forms![CustomerServiceCalls]![txEAN]
(at minimum you should try altering the SQL so that the WHERE clause has this formatting for the form reference

So you would have (in part) (also note here, I've changed the dot (.) to a bang (!) - denotes part of a collection and not part of an object property.
Expand|Select|Wrap|Line Numbers
  1. SELECT [CustomerServiceCalls]![Customer First Name]
  2.    , [CustomerServiceCalls]![Customer Last Name]
  3.    , (...)
  4. FROM [CustomerServiceCalls]
  5. WHERE ((([CustomerServiceCalls]![Address Number])=
  6.    Forms![f_CustomerServiceCalls]![txEAN])
  7.    (...) ;
I would advise changing your form name to:
f_CustomerServiceCalls, at least from a human perspective it makes it less confusing as to what you are referring to - I have done so above as an example.

I notice that you are using spaces and special characters within the field names. Although allowed, this is not the best practice and may cause you other issues. ESPECIALLY the special characters such as the question mark, the exclamation mark etc... as often these have significance to the SQL engine

-Problem names and reserved words in Access (article by Allen Browne)

Learn about Access reserved words and symbols (Article by MS)
Access reserved symbols
(...)
The following symbols must not be used as part of a field name or as part of an object name:
. / * ; : ! # & - ? " ' $ %
The spaces between words is less of an issue; however, can cause you growing pains as you code, you MUST use the square brackets around the field names (best practice to do so anyway IMHO), and if you ever upsize to one of the Server based databases some of them may not like the extra spaces - in any case, extra work for you :) .

+ Just a suggestion, your field names are VERY long which makes your SQL and potentially your Macro script or VBA scripts very lengthy to program -- AND there is a character limit you may run in to depending on how you are developing your project. Thus you might consider changing things such as
[Description of Further Action] to something like [DofFrthrActn], use the description portion of the field in table design view to provide the nicer details (which will show up at the bottom of the access interface) and in your forms change the labels so that the user interface is friendly
Jul 22 '16 #4
JBrinovcar
3 New Member
Thanks for your reply! I'll try your suggestions and reply back.
Jul 26 '16 #5

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

Similar topics

2
1766
by: Mel | last post by:
is there a way to disable text field history from poping up when the user enters a command that is already in the hitsory cache ? i know i can turn it off from WinDoze preferences. can...
4
2389
by: N. Graves | last post by:
Hello; I have a table that is equipment. This table has a filed called Owner and that Owner filed is Looked up from a table called employee. and the query request the serial number of the...
8
18300
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
2
1731
by: okosh | last post by:
Hello to All, I have a date field on my app that uses an ActiveX calendar. A calculation that takes place after "On Lost Focus" function. How can I prevent the use from entering the date with out...
3
1810
by: Alexio | last post by:
I need to enter a date into a text field when form is loaded. However I need this date to be static when the form is opened at a later date. I have the text box set to readonly. Will this be...
7
3103
by: kirkgilbert | last post by:
I am trying to do an onchange event in a form using a text field. The form is tied to a record set that is part of a repeated region. One the first record when I edit the data it works perfectly. ...
4
2056
anurag275125
by: anurag275125 | last post by:
Hello, can anyone please tell me how can I create a input text field in form that can only accept numbers. thanks
1
2292
doma23
by: doma23 | last post by:
I have a field in a query that contains numbers and text (text field): C/R: IIf(<=0;"n/m";/) I need to export this query to Excel in a number format, so I can easily manipulate the data later....
4
2366
by: dekk | last post by:
I am trying to populate a text field from the combo selection. I have the following update event in the combo box Private Sub cboContract_AfterUpdate() Me!txtDesc = Me!cboContract.Column(1)...
9
1005
by: sarab2015 | last post by:
I have built an Access database for a medical department to track patient appointments. We have a comment line (text) to enter free text information as needed. Intermittently my users are finding...
0
6904
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
7034
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
7076
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
6886
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
5324
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
4768
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
4472
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
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
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 ...

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.