473,408 Members | 1,871 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,408 software developers and data experts.

MS ACCESS 2007 queries that present you with a parameter value dialogue box

I have designed a query in Access 2007. What verbiage do I use in the criteria row of the field in question in order to have the user presented with a dialogue box that tells him that he needs to enter a parameter before the query is run? I want my query designed like such because the users are not tech-savy when it comes to designing a query. The field in question is labelled as "comment".
Feb 6 '12 #1
13 2862
NeoPa
32,556 Expert Mod 16PB
Any text within brackets - [] - which doesn't match up to a valid reference will be treated as a prompt for a value from the operator.
Feb 7 '12 #2
I know about the brackets, but it doesn't work. I'm trying to query products that have latex, for example, in them. Because "latex" appears in a field with other words, all separated by a comma, I put in my box [enter *comment*]. I've tried different versions and nothing works.
Feb 7 '12 #3
NeoPa
32,556 Expert Mod 16PB
So, why didn't you ask that question - instead of the one you did ask. I answered your question - the question for this thread - correctly already (If that doesn't work for you then you're simply not using it correctly).

If you want to filter a field called [Comments] such that it finds records where the field contains the value that you want to prompt for, then you would need something like :
Expand|Select|Wrap|Line Numbers
  1. WHERE [Comments] Like '*' & [Enter filter value] & '*'
The [Enter filter value] part is an example and illustration of the answer to the original question.
Feb 7 '12 #4
Let me be clearer because the above does not work. In my query, I have three fields (product, dosage form, and comment). This query is built from a "product" table which consists of several fields, one of which is "comment". The "comment" field is made up of words separated by commas. For example, for a given product, there might be in the "comment" field the following text: FD&C No. 1, latex, non-kosher, sulfites.
I want to design my query in such a way that when another user uses that query, he will not have to input, for example, "latex" in the design view. I want the user to click the appropriate query button in the switchboard. When the user clicks that specific query button, a dialog box will appear that will prompt the user to enter "latex" because he will want to search for all products containing latex. When I do this with the expression that you have given me, it returns zero results and I know for a fact that this is not possible. If I do my query manually by entering "latex" in the design view, I get results.

Thanks for any help you can provide me.
Feb 7 '12 #5
NeoPa
32,556 Expert Mod 16PB
Larocqgi:
Let me be clearer because the above does not work.
Clearer's a great idea, but I already explained that if it's not working then you're not doing it correctly.

Let's start with clearer anyway. A good (and fairly obvious) way to be clear is to include details of :
  1. Exactly what you're doing (The SQL executed).
  2. The layout of the data you're working with (Table [Product] and Fields [Product], [Dosage Form] & [Comment]).
  3. The source data (Some example records that illustrate the point).
  4. The test data ("latex").
  5. The actual results (Empty).
  6. The expected results.

You've already indicated what results you're getting (#5), which is good, and what you expect (#6) would be pretty obvious when we can see the data used. You've also supplied the filter value you used in your test (#4) and most of the details of your data layout (#2), although FieldType of [Comments] may be important if it's other than Text - EG. Memo. If you provide the SQL (#1) and the sample data (#3) I will endeavour to determine what is going wrong.
Feb 7 '12 #6
Boy, you ask tough questions! Let's see if I understand your questions.

Data Type is "text".

#3 Sample Data: The property sheet for my "comment" field indicates that the control source is "comment".

#1 SQL: If the user was to do the query manually, in the design view of the query, I would enter in the criteria row of the "comment' field, Like "*non-kosher*". This will bring me accurate results. It will give me a list of products which are non-kosher. But what I need is what do I enter so that the user will only need to type "non-kosher" in a parameter value dialog box when he clicks on the query button of the switchboard.

Thanks,
Feb 7 '12 #7
NeoPa
32,556 Expert Mod 16PB
Let me see if I can explain myself better. I'll return to the original order if I may, as that seems to make more sense to me.

#1 - SQL - I need you to post the SQL you were using when this went wrong. EG :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Product]
  2.      , [Dosage Form]
  3.      , [Comment]
  4. FROM   [Product]
  5. WHERE  ([Comment] Like '*' & [Enter filter value] & '*')
This is just an example. I need you to post what you used.

#3 - The Source Data - I need you to post some data records that reflect your example data. EG :
Expand|Select|Wrap|Line Numbers
  1. Product  Dosage Form  Comment
  2. A        X1           FD & C No 1, Nonkosher, Sulfites
  3. B        X1           Latex, Sulfites
  4. C        X1           Nonkosher, Sulfites
  5. D        X1           Latex
  6. E        X1           FD & C No 1, Latex, Sulfites
  7. F        X1           Nonkosher
In this example I would expect to see results including products B, D & E.
Feb 8 '12 #8
NeoPa, you have #3 (source data) to perfection. No need to add to this one.

As for the SQL, I used the PRODUCT table, and the following fields from that table: PRODUCT, DOSAGE FORM, COMMENT. In the COMMENT field, I have tried the following expressions in the "criteria" row:

1. [enter comment] This causes dialog box to appear when I run the query, but zero returns.
2. Like [enter*comment*] This causes dialog box to appear when I run the query, but zero returns.
3. WHERE [Comments] Like '*' & [Enter comment] & '*'. This causes dialog box to appear when I run the query, but zero returns.

Thanks,

Ginette
Feb 8 '12 #9
NeoPa
32,556 Expert Mod 16PB
Let's see if we can't put this one to bed Ginette. Let me start by saying that option #3 in your list is exactly as I would expect. This should work.

However, and this is quite a big however, I need exact details from you for this, not just general indications. As such, I need you to post your example data precisely (not simply a general indication, but exact details - although not all records need be included). I need you to post your exact SQL - copy pasted from your project.

It seems clear to me that something, somewhere, is not exactly as represented. This is quite common. People can overlook details when relating information. I myself struggled with some data just yesterday when the total value worked out by my program was different from my adding up all the individual values. I had to look and look until I noticed a value I'd got as 15 but should have been 11.

There is nothing wrong with the setup as you've described it, so I assume there is a minor detail wrong somewhere, which I can identify if I have direct access to all the information, but not from general indications (Certainly not those I have already as they're checked and confirmed as fine by me - yet you're reporting they're not working for you).

Another alternative for you is to attach your database. If you'd like to take that approach, you will need to follow the instructions in Attach Database (or other work) very carefully. If you manage that properly I will happily look into it for you. Clearly, I'll then need less from you in the way of posting information. I will endeavour to explain any problem I find either way.
Feb 8 '12 #10
Let's see if I can give you what you want without sacrificing privacy.

In one of my records for "comments", I have: FD&C Blue No. 1, animal-sourced gelatin, sunflower oil, sulfites, chemical solvents (acetic acid, ethanol, n-butyl, isopropyl alcohol), non-kosher, no dedicated mfg'ing line, Ca, Mg, K, Na, sorbic acid as preservative

In another record for "comments" I have: Numerous artificial colours, animal-sourced gelatin, sunflower oil, sulfites, chemical solvents (acetic acid, ethanol, n-butyl, isopropyl alcohol), non-kosher, no dedicated mfg'ing line, Ca, Mg, K, Na, sorbic acid as preservative

And lastly, here is a snapshot of my query in "design view".

Thanks.
Attached Files
File Type: docx Query Design View.docx (36.1 KB, 379 views)
Feb 8 '12 #11
NeoPa
32,556 Expert Mod 16PB
Panic over. All is now clear :-)

Let's start by giving you a link that will make the sharing of SQL code, and queries generally, much easier for you - Extracting/Updating SQL from a QueryDef. You can use it to update your query with my suggested solution code if you like.

Anyway, the problem is that the format of the solution I suggested is specifically for the SQL version of the query. It cannot be used, exactly as suggested, on the criteria line. I missed this earlier (You explained it correctly) as it's very common for members to use incorrect terms in their explanations and I assumed you'd understand that this was not something to put into the Criteria slot. My error.

The Criteria value could be done as :
Expand|Select|Wrap|Line Numbers
  1. Like '*' & [Enter comment] & '*'
The whole SQL could be :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Product]
  2.      , [Dosage Strength/Dosage Form]
  3.      , [Comment]
  4. FROM   [Product]
  5. WHERE  [Comment] Like '*' & [Enter comment] & '*'
Feb 8 '12 #12
NeoPa, you did it!! THANK YOU. I just tried the new code in my criteria row and it works. I'm so relieved! Thanks again. :)
Feb 9 '12 #13
NeoPa
32,556 Expert Mod 16PB
LarocqGi:
NeoPa, you did it!!
Always with the surprise!! :-D

I'm glad we got there in the end Ginette :-)
Feb 9 '12 #14

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

Similar topics

2
by: Christine | last post by:
I am struggling to learn to use Access almost on my own, and have written a query that needs to have a parameter. The query I wrote includes in the Criteria of the design view, under the column...
2
by: Christine Brandel | last post by:
The code for the query I have written is: SELECT .,.,.,. FROM dbo_census WHERE (((.)=))); That code results in the parameter value request being made twice before the information I want...
4
by: David Kates | last post by:
I was one of the few who was able to download the Access 2007 runtime when it was available for a short time. I installed it but cannot figure out how it runs an Access 2007 database. There is no...
1
by: asmith | last post by:
I am trying to add a combo box into a query criteria cell. I have made forms to direct this but have been unable to get the query to bring up the form. Using "Forms!! " will not open the form. Al
10
Megalog
by: Megalog | last post by:
Hello all! This is my first posting here, although I've been lurking here for months and getting lots of help & tips from the past posts here. I'm in the process of updating our company's Access...
2
by: Bob | last post by:
Hi, In runtime environement my access 2007 application dont show the Navigation Pane, anybody have this problem ? Thank's for reply Bob
2
kmartinenko
by: kmartinenko | last post by:
Hi everyone, I have several combo boxes on my form, and while I have designated a column head, I cannot figure out how to default to the column head value. What I really want is for all of my...
6
by: lisacrowe | last post by:
I have a simple database recording complaints. A crosstab query is based on a query which returns resolved complaints only. The crosstab has the field Complaint Type as a row heading and Outcome as a...
1
by: mramnaveen | last post by:
Hi, Please help me. I have around 15 access queries that i run every day. I want to find out a way where, all these queries could be consolidated and I just click run once and all the 15 queries...
0
by: Hansens | last post by:
Hi, I'm fairly new to using access and my VB skills are very limited. I built a form that had unbound text boxes that act as parameters in the queries that provide the form with field values....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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,...
0
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...

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.