473,486 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

List records sorted into category groups with subheadings

41 New Member
I have a form which lists all records for the user to choose which ones to print. Its a continuous form with a checkbox for each record, bound to a "selected" yes/no field in the table.This works well for what it is, however I really want to split my list into categories. I can do this in reports but don't know how in forms and searching has been unsuccessful.
In my table I have fields for FoodCategory, RecipeName, Selected, and some others. I want to make a list like:

FoodCategory1
--RecipeName1
--RecipeName2
FoodCategory2
--RecipeName3
etc...

I want to be able to select multiple RecipeNames and even if possible to be able to select a whole FoodCategory at once.
Please can someone help with this?
Jenny
Jun 23 '07 #1
7 2892
FishVal
2,653 Recognized Expert Specialist
I have a form which lists all records for the user to choose which ones to print. Its a continuous form with a checkbox for each record, bound to a "selected" yes/no field in the table.This works well for what it is, however I really want to split my list into categories. I can do this in reports but don't know how in forms and searching has been unsuccessful.
In my table I have fields for FoodCategory, RecipeName, Selected, and some others. I want to make a list like:

FoodCategory1
--RecipeName1
--RecipeName2
FoodCategory2
--RecipeName3
etc...

I want to be able to select multiple RecipeNames and even if possible to be able to select a whole FoodCategory at once.
Please can someone help with this?
Jenny
Hi!

I would like to suggest you the following interface:

MainForm (Food Categories)
--Subform (Receipe Names)

Subform contains checkbox you've mentioned.
MainForm contains unbound checkbox which when updated updates checkboxes in underlaying subform.

If this is what you want I will help you with design and coding.
Jun 23 '07 #2
KiwiGenie
41 New Member
Hi..thanks for the reply. I am still very much an access newbie and I'm not sure I understand how the checkboxes would work, but it really got me thinking and I wondered would something like this work:
Unbound main form
--Combo box - FoodCategory
--Listbox - Recipe names matching chosen category, hopefully would be able to include an "all" option to select a whole category.

Then when a recipe name is clicked on in the listbox, a subform datasheet shows up listing selected recipe names. Then I can see which ones will be printed, maybe if possible choose to unselect some, then preview or print.
Hope I'm making some kind of sense ;) I haven't had time to try out much of this yet, so far I have the combo box working to fill the listbox. Any more ideas or guidance very much appreciated :)
Jun 24 '07 #3
KiwiGenie
41 New Member
Just to update I have added the subform now and added the following code to the listbox:

Expand|Select|Wrap|Line Numbers
  1. Private Sub RecipeName_Click()
  2.  
  3. Dim strSelected
  4.  
  5. strSelected = strSelected & "SELECT * FROM tblRecipes WHERE tblRecipes.RecipeName ='" & Me!RecipeName & "'"
  6. Me.SubfrmSelected.Form.RecordSource = strSelected
  7.  
  8. End Sub
This works if I click on one recipe name from the listbox, but if I click on another the first name is replaced by the second. How can I get it to remember all the recipe names that I've clicked on. (I will have a "clear" button somewhere to clear the subform). I made the subform an unbound form, is this the problem?
Jun 25 '07 #4
FishVal
2,653 Recognized Expert Specialist
Just to update I have added the subform now and added the following code to the listbox:

Expand|Select|Wrap|Line Numbers
  1. Private Sub RecipeName_Click()
  2.  
  3. Dim strSelected
  4.  
  5. strSelected = strSelected & "SELECT * FROM tblRecipes WHERE tblRecipes.RecipeName ='" & Me!RecipeName & "'"
  6. Me.SubfrmSelected.Form.RecordSource = strSelected
  7.  
  8. End Sub
This works if I click on one recipe name from the listbox, but if I click on another the first name is replaced by the second. How can I get it to remember all the recipe names that I've clicked on. (I will have a "clear" button somewhere to clear the subform). I made the subform an unbound form, is this the problem?
Hi!

I was somewhat busy. Sorry.
I've read your posts. It is not very difficult to implement an interface you like. But first of all to avoid misunderstanding plz provide the tables structure including field types and PK / FK relationships (I mean particulary table of RecipeNames and table of FoodCategories).

P.S. The code you've posted is supposed to do exactly what you are getting (each time executed it replaces subform RowSource with a new query returning one recipe name).
The easiest way to do multiple selection is to update Y/N field in tblRecipes you've mentioned in msg#1.
SQL:
UPDATE tblRecipes SET tblRecipe.IsSelected = Yes
WHERE tblRecipes.RecipeName="'" & Me!RecipeName & "'";
Now you can easily require to the subform an report records where "tblRecipe.IsSelected = Yes" and require records where "tblRecipe.IsSelected = No AND tblRecipe.FoodCategory="&Me!FoodCategory to the Listbox.
A simple update query
UPDATE tblRecipes SET tblRecipe.IsSelected = No;
will clear selection on user request.

P.P.S. Anyway to make my help more certain plz provide tables structure. To provide current form design and code would be nice as well. ;)
Jun 25 '07 #5
KiwiGenie
41 New Member
Hi..First off, no worries about any delays, I get busy too! Besides I've had time to play round and learn a bit more about what I'm trying to do.
P.S. The code you've posted is supposed to do exactly what you are getting (each time executed it replaces subform RowSource with a new query returning one recipe name).
The easiest way to do multiple selection is to update Y/N field in tblRecipes you've mentioned in msg#1.
I came to that conclusion last night after trying it with the listbox on multi-select, and using the ItemsSelected property. I got this to work, but when I changed categories in the combobox then clicked on a recipename the previous selections would disappear from the subform. What I have now appears to work (so far)...
Here are my relevant table structures:
tblRecipes:
-RecipeID - AutoNumber (PK)
-RecipeName - Text
-FoodCategory - Text (FK to tblFoodCategories.FoodCategory)
-Source - Text
-Instructions - Memo
-Selected - Y/N
tblFoodCategories:
-FoodCategory - Text (PK)

And my current form design etc:
Main form
-FoodCategory (ComboBox with RowSource = SELECT tblFoodCategories.FoodCategory FROM tblFoodCategories;)
Expand|Select|Wrap|Line Numbers
  1. Private Sub FoodCategory_AfterUpdate()
  2.  
  3.     If IsNull(Me!FoodCategory) Then
  4.       Me!Subfrm1.Form.RecordSource = ""
  5.     Else
  6.       Me!Subfrm1.Form.RecordSource = "SELECT * FROM tblRecipes WHERE tblRecipes.FoodCategory ='" & Me!FoodCategory & "'"
  7.     End If
  8.    Me.Requery
  9. End Sub
  10.  
-Subfrm1 (Continuous form)
--RecipeName - TextBox - ControlSource = RecipeName
--CheckSelected - Checkbox - ControlSource = Selected
Expand|Select|Wrap|Line Numbers
  1. Private Sub CheckSelected_Click()
  2.   Me.Parent.SubfrmSelected.Form.RecordSource = "SELECT * FROM tblRecipes WHERE tblRecipes.Selected = -1;"
  3.   Me.Parent.SubfrmSelected.Requery
  4. End Sub
-SubfrmSelected (Datasheet Form)
--RecipeName - TextBox - ControlSource = RecipeName
--FoodCategory - TextBox - ControlSource = FoodCategory

Thank you for your help in getting this far, hope its clear what I have so far, and sorry for the long post!
Jenny
Jun 26 '07 #6
KiwiGenie
41 New Member
Ok, something is wrong already, when I select the first recipe, nothing happens in the subform, then when I select another recipe, the first one shows up, select a third and the second shows up...
Any ideas?
Jun 26 '07 #7
FishVal
2,653 Recognized Expert Specialist
Ok, something is wrong already, when I select the first recipe, nothing happens in the subform, then when I select another recipe, the first one shows up, select a third and the second shows up...
Any ideas?
Ok. Its completely normal behaviour as you try to requery subform with selected recipes while the record you've changed is not yet saved in the table (pencil sign on a record selector).

I propose the following.
  • you should handle changing of the CheckBox on AfterUpdate event
  • you should first of all force the current record to be saved in db (e.g. "Referesh" method)
  • the row in CheckSelected_Click sub there you change subform recordsource is not actually needed as you don't change anything :)
Below is an example of code
Expand|Select|Wrap|Line Numbers
  1. Private Sub CheckSelected_AfterUpdate()
  2. Me.Refresh
  3. Me.Parent.SubfrmSelected.Requery
  4. End Sub
  5.  
Good luck.
Jun 27 '07 #8

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

Similar topics

3
4588
by: Rich Protzel | last post by:
Hello, So my table contains say 100,000 records, and I need to group the categories in fld1 by the highest count of subcategories. Say fld1 contains categories A, B, C, D, E. All of these...
1
2753
by: Melissa Kay Beeline | last post by:
OK, here's the sitch : we have an access control system at work that registers ever entry/exit of every employee. I recently made some queries in Access so the ppl in HR could make reports (who...
2
3826
by: Todd | last post by:
Hi. I want to sort the records on my form (using either a continuous form or a datasheet) by the unbound "description" column in a combo box on the form (or in the datasheet.) Here's a rough...
3
22062
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** it's been a while since i have poseted to this newsgroup, but for a long time i was not programming at all. but now that i am out of...
5
17630
by: Someone | last post by:
I wish to use a sorted list to store lists of strings. I am unsure as to how things work. I want to do something like: SortedList list = new SortedList(); for(...loop for string...) { if( !...
9
2197
by: ECUweb | last post by:
Hi, I need to sort out a list of records based on the field "Weight" and then allocate points (from 1 to 10) to each record (in another field "Points") depending on the position of the record in the...
7
2225
by: beginner | last post by:
Hi Everyone, I have a simple list reconstruction problem, but I don't really know how to do it. I have a list that looks like this: l= What I want to do is to reorganize it in groups,...
4
1968
by: Clint Schaefer | last post by:
Apologies in advance. I've seen similar questions, but none of the solutions seem to be working for me... I have a form that allows a user to select mutiple items (payroll deduction codes) in a...
3
2799
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, Can I expect a clever sorting algorithm behind the Sort() function for the List<Tclass? Can't find anything on the net that says anything about this. regards Jesper
0
6964
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
7173
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...
1
6839
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
7305
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...
1
4863
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
4559
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
1378
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 ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
259
bsmnconsultancy
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...

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.