473,408 Members | 1,854 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.

Limiting a list box to a query, in a subform made of two tables

I am creating a restaurant meal ordering system. I want to limit the meals that can be ordered to only those that are in use (i.e. in the form holding meal details the 'in use' field is true). I can't create the right query to link to the list box though.

tblOrder
OrderID (key)
TableID (foreign key)
GuestsArrived
GuestsLeft
Notes

tblOrderDetail
OrderID (key)
ItemID (key)

tblItem
ItemID (key)
Name
ItemTypeID (foreign key)
NumberInStock
Re-OrderLevel
Cost
Notes
InUse

The main form is 'frmOrder' and the subform contains 'OrderID' and 'ItemID' from 'tblOrderDetail', 'Cost' and 'Notes' from 'tblItem'.

Using 'Item ID' (tblOrderDetail) and 'In Use' in a query produces a long list with multiple instances of each meal.

Using ''Name' and 'In Use' produces the correct query but when you link it to a list box in the form I mentioned and then select an option from that list box it puts that selection in every record in that order?
Feb 19 '07 #1
7 1685
MMcCarthy
14,534 Expert Mod 8TB
Try this as the recordsource for your subform and let me know the results ...

Expand|Select|Wrap|Line Numbers
  1. SELECT tblOrderDetail.OrderID, tblItem.ItemID, tblItem.Name
  2. FROM tblOrderDetail INNER JOIN tblItem
  3. ON tblOrderDetail.OrderID=tblItem.OrderID
  4. WHERE tblItem.InUse = -1;
  5.  
Mary
Feb 20 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
Sorry just re-read the title. Set the list box row source to ...

Expand|Select|Wrap|Line Numbers
  1. SELECT tblItem.ItemID, tblItem.Name
  2. FROM tblItem
  3. WHERE tblItem.InUse = -1;
  4.  
Mary
Feb 20 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Using ''Name' and 'In Use' produces the correct query but when you link it to a list box in the form I mentioned and then select an option from that list box it puts that selection in every record in that order?
Not sure what is going on here.

1. Why are you using a list box instead of a drop down box?
2. Is your subform recordsource the same as the previous answer I gave in Post #2?
3. Is the control source of the listbox set to the field in which you want to store the ItemID?

Mary
Feb 20 '07 #4
I think I mean a drop down box, I'm now using the control Access calls a combo box. Changing the control source to ItemID solves the problem about all the records showing the same entry that i mentioed in post #1, thanks. The code from post 2 works, but it shows the Item IDs in the drop down box, it would make more sense to the user if it showed the meal names?
Feb 20 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
I think I mean a drop down box, I'm now using the control Access calls a combo box. Changing the control source to ItemID solves the problem about all the records showing the same entry that i mentioed in post #1, thanks. The code from post 2 works, but it shows the Item IDs in the drop down box, it would make more sense to the user if it showed the meal names?
Open the properties of the combobox and go to the Column Widths property. Set to 0cm;5cm and you should now see the item name. Setting the first column width to 0 will hide it.

Mary
Feb 20 '07 #6
Thanks, you also needed to set the colum count to 2 before the list became visible, but now it works fine. Thank you :)
Feb 20 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
Thanks, you also needed to set the colum count to 2 before the list became visible, but now it works fine. Thank you :)
You're welcome.

Sorry I shouldn't have assumed the column count was set to 2. ;)

Mary
Feb 20 '07 #8

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

Similar topics

0
by: Dalan | last post by:
I'm not certain if this is doable in the manner explained below, but I'm certain that there have been Access developers who have done something similar. So whatever insight and assistance that can...
2
by: Josh Felker | last post by:
Hey everyone. I have a daily log form with my investing info. In that form I have 2 subforms, the first shows my profits on all the stocks I traded that day, the second shows my profits on...
5
by: Andrew | last post by:
I've got two tables in my DB, a Client table and an Event table. There are many events for each client. The form I designed is based off of the Client table and the subform within it is sourced...
0
by: Jean | last post by:
Hello everybody. Can someone point out please what is wrong with my work? What I have so far: People take part in experiments, and a record is made in tblExperimentInstances. There are a number...
0
by: Igor Kramarsic | last post by:
Hello, my problem is maybe simple but I not see good solution. I have one form with subform. Form is made from table with one field and can not be added new staff. Subform is continius form...
1
by: sparks | last post by:
I have a main table with teacher names and students I can put this in a subform and filter by teacher name so I have a list of her students in a sub form. the problem I have is this is created in...
23
by: mforema | last post by:
Hi everybody, I need to create a query that will search based on keywords and major categories. My tables are set-up as follows: tblLiteratureArticles: Abbreviation(FK) ArticleID(PK) Author...
2
by: cluless | last post by:
I'm relatively new to access, and I'm trying to create a form where if I click on a selection of a list box the subform below it will be filtered automatically on click (I was hoping I didn't need a...
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
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
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...
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,...

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.