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

Select multiple criteria within a field - pass to report filter

I have a field called ingredients where multiple ingredients can be
contained in one record (client request). Now when a report is run I
need to prompt a user to determine which records to display which could
be all of the below ingredients or just 1.

Order ID Ingredients
1 PEP, SAU, MSH, GP
2 SAU
3 PEP

If user only wants report to display orders for PEP and SAU, what type
of prompt/filter must I create ?

Thanks in advance ?

Aug 31 '06 #1
6 3424
This is classic denormalized design. Ingredients should be listed
individually in a child table. then you can use OR to filter for the
exact set of ingredients you need.
If this were my database, I'd create a table of (OrderID, Ingredient)
and then use Split to return an array of ingredients, which you an loop
through and append to your OrderIngredients table.

Then you could populate a listbox with ingredients and pass the
selected items to the open event of a report to be used as a filter.
Create a function to return the list...

Aug 31 '06 #2

What do you mean by Split ?
pi********@hotmail.com wrote:
This is classic denormalized design. Ingredients should be listed
individually in a child table. then you can use OR to filter for the
exact set of ingredients you need.
If this were my database, I'd create a table of (OrderID, Ingredient)
and then use Split to return an array of ingredients, which you an loop
through and append to your OrderIngredients table.

Then you could populate a listbox with ingredients and pass the
selected items to the open event of a report to be used as a filter.
Create a function to return the list...
Aug 31 '06 #3

po*******@gmail.com wrote:
What do you mean by Split ?
Your design is a little off, although I guess you could use InStr() to
figure out if a value was in your list.

Split is a VB function. Open up a code module, go to help (F1) and
read all about it. It will basically take a delimited string and turn
it into an array.
e.g., varNumbers=Split("One, Two, Three",",") would return:
varNumbers(0)=1, varNumbers(1)=2, varNumbers(2)=3
so then I could just iterate through the subscripts and write
them to a table.

IF your list is comma-delimited, you should be able to do something
like

Sub NormalizeIngredientList(byval strIngredientList as string)
dim varIngredients as Variant
'--will return an array of ingredients
varIngredients=Split(strIngredientList,",")

'---loop through the ingredients that are now in the array,
varIngredients
'---lbound() returns the lowest subscript in the array, and
ubound() returns the highest.
for intCounter=lbound(varIngredients) to ubound(varIngredients)
'---write the values to a child table
strSQL="INSERT INTO RecipeChild(RecipeID, IngredientID)
VALUES (" & Me.Controls("txtRecipeID"),varIngredients(intCount er) & ")"
DBEngine(0)(0).Execute strSQL, dbFailOnError
next intCounter

End Sub

Aug 31 '06 #4
On 31 Aug 2006 13:59:18 -0700, po*******@gmail.com wrote:
What do you mean by Split ?

pi********@hotmail.com wrote:
>This is classic denormalized design. Ingredients should be listed
individually in a child table. then you can use OR to filter for the
exact set of ingredients you need.
If this were my database, I'd create a table of (OrderID, Ingredient)
and then use Split to return an array of ingredients, which you an loop
through and append to your OrderIngredients table.

Then you could populate a listbox with ingredients and pass the
selected items to the open event of a report to be used as a filter.
Create a function to return the list...
If each field in each record held just one item of data you wouldn't
need to be asking how to do this. :-(

See VBA help on the Split function.
It takes data in one record field, such as
book,pencil,eraser
and separates it into 3 different parts based upon the position of the
comma.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Aug 31 '06 #5
Even if I normalize the data I am unsure how this helps my report
dilemma. Let me use a better example:

Normalized Data for Property Table
PropertyID Rooms
LincolnTower A
LincolnTower B
LincolnTower C
LincolnTower D
ForestEstate A
ForestEstate B

Report must look like this

Property Rooms
LincolnTower A,B,C,D
ForestEstate A,B

User must have ability to filter on Rooms when viewing the report

fredg wrote:
On 31 Aug 2006 13:59:18 -0700, po*******@gmail.com wrote:
What do you mean by Split ?

pi********@hotmail.com wrote:
This is classic denormalized design. Ingredients should be listed
individually in a child table. then you can use OR to filter for the
exact set of ingredients you need.
If this were my database, I'd create a table of (OrderID, Ingredient)
and then use Split to return an array of ingredients, which you an loop
through and append to your OrderIngredients table.

Then you could populate a listbox with ingredients and pass the
selected items to the open event of a report to be used as a filter.
Create a function to return the list...

If each field in each record held just one item of data you wouldn't
need to be asking how to do this. :-(

See VBA help on the Split function.
It takes data in one record field, such as
book,pencil,eraser
and separates it into 3 different parts based upon the position of the
comma.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sep 1 '06 #6
simple. Use fConcatChild to do that.
Test it out on NWind first, because that's where it was designed to
work. Then you can work out why your first few attempts may not be
working. (I don't think I ever got that one right the first time...
maybe I'm just too ADHD to pay attention that long!)

http://www.mvps.org/access/modules/mdl0004.htm

Sep 1 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Powell | last post by:
Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to do it in Javascript (I...
4
by: Therese A. Sorna | last post by:
Hello all... I am using Access 2002, and am trying to find a way for a user to be able to select multiple entries from a drop-down list. I am hoping that given a list as such: a b c d
5
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...
3
by: slayerx | last post by:
i've designed a query but i'll want the user to change the criteria within the report. so as the report is open it will show a combo box with a list of names taken from the field in the query, is...
7
by: fleece | last post by:
I set up a form for searching criteria and pass the searching result to a report. On this report there is an unbound text box (=.Filter) and shows the searching criteria. It works fine when searching...
3
by: developing | last post by:
Hello How do I specify multiple criteria for FindFirst or FindRecord (or anything else) that takes the criteria from a form. (text field and number field) edit: this will be in the after...
3
by: emgallagher | last post by:
I have a form which lists studies. People can filter the form based on details about the study, such as the study type. Currently users filter via the right click method. I would like to be...
0
by: ChadK | last post by:
I am trying to open a report based on what the user selects on a form. Each individual criteria works but when I try to combine to pass multiple criteria it doesn't. I have read what I can find on...
0
by: Neil Cho | last post by:
Hello, I am VERY very new to MS Access and here is my question - I created a form, which has various drop down menus and I want the users to select different criteria and run a report. So it's...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...

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.