Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    afiasiddiqa is offline Novice
    Windows 11 Office 365
    Join Date
    May 2024
    Posts
    5

    how to add categories and sub categories in subform


    I have below 4 tables.Table1:ID, OHN (this is primary key), Dob, Type of referral, Reason of referral, date of referral received , clinician

    tblInjurySubcategory,tblNatureofInjury,tblPatient_ injury. I have created a Physio Form. I have tried to create subform with category and sub category. It is showing categories/sub categories but when i select for example, Shoulder then it dhoesnt show related sub categories for shoulder. Not sure, what i am doing wrong. Pease can you help
    Attached Thumbnails Attached Thumbnails relationship diagram.jpg   tblpatient_injury.jpg   tablNatureofInjury.jpg   tblinjurysubcategory.jpg   Fprm.jpg  


  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,821
    Hi

    There are numerous things wrong with your database.

    You should not be using Text data Type as a Primary Key.

    Each table should have an Autonumber Long Integer Primary Key.

    Your tables should not have fields set as Lookups. Google the Evils of Lookup fields in Access Tables.

    Your relationship should be as follows.

    Then using MajP's example you should have a Main Form based on the tblReferrals
    With a Subform based on tblPatientInjury
    In the Subform you would create Cascading Combox's.

    1st Combobox looks up the tblNatureOfInjury
    2nd Combobox would contain the list of SubCategories
    Attached Thumbnails Attached Thumbnails RI.png  

  4. #4
    Join Date
    Apr 2017
    Posts
    1,792
    Quote Originally Posted by mike60smart View Post
    Then using MajP's example you should have a Main Form based on the tblReferrals
    With a Subform based on tblPatientInjury
    In the Subform you would create Cascading Combox's.

    1st Combobox looks up the tblNatureOfInjury
    2nd Combobox would contain the list of SubCategories
    l
    Another option is to have 2 unbound combos in main form to select injury category and subcategory, and have the subform linked to those unbound combos too. Or even have the unbound main form with those combos, link the subform to those combos only, and select the patient in subform.

    Any new record added into subform will get category and subcategory id's from those unbound combos automatically.

    Links to unbound controls can be created only when editing subform properties!

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    In addition to the comments received so far, I recommend no field names with embedded spaces. They will come back to haunt you.

  6. #6
    afiasiddiqa is offline Novice
    Windows 11 Office 365
    Join Date
    May 2024
    Posts
    5
    Quote Originally Posted by mike60smart View Post
    Hi

    There are numerous things wrong with your database.

    You should not be using Text data Type as a Primary Key.

    Each table should have an Autonumber Long Integer Primary Key.

    Your tables should not have fields set as Lookups. Google the Evils of Lookup fields in Access Tables.

    Your relationship should be as follows.

    Then using MajP's example you should have a Main Form based on the tblReferrals
    With a Subform based on tblPatientInjury
    In the Subform you would create Cascading Combox's.

    1st Combobox looks up the tblNatureOfInjury
    2nd Combobox would contain the list of SubCategories
    Thank you so much for the detailed reply and explaining it to me. I have designed the database as per your advise. I had the Main form designed on the basis of Table1 and subform on Tbl PatientInjury .Everything was working fine, its just all subcategories were appearing in combobox when in actual it should show only those selected in Category field. For example , if i select shoulder then only its sub category should appear in combo box.

    Now comboboxes are not appearing in the sub form. Not sure why🤦*♀️

    Would be able to advise please.

    Thank you so much for your help
    Attached Thumbnails Attached Thumbnails Untitled.jpg  

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,821
    Hi
    Can you upload your latest version of the database?

  8. #8
    afiasiddiqa is offline Novice
    Windows 11 Office 365
    Join Date
    May 2024
    Posts
    5
    I have added the zip file .

    Many Thanks
    Attached Files Attached Files

  9. #9
    afiasiddiqa is offline Novice
    Windows 11 Office 365
    Join Date
    May 2024
    Posts
    5
    and this is the initial database file but this is with alpha numeric primary keys

    Many Thanks
    Attached Files Attached Files

  10. #10
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,821
    Hi

    The subform needs to be set as a Continuous Form vice Datasheet.

    You should name the Forms with the prefix "frm" vice "tbl"

    The first Combobox looks up the list of Categories from the tblNatureofInjury.

    The second Combobox looks up the list of Subcategories.

    Look at the properties of the 2nd Combobox where a reference is made to the 1st Combobox to limit the list.
    Attached Files Attached Files

  11. #11
    afiasiddiqa is offline Novice
    Windows 11 Office 365
    Join Date
    May 2024
    Posts
    5
    Hi,

    Thank you so much. Is InjurySubCat_FK hidden behind SubCat? as when i click on just drop down arrow the it shows the properties with query in Row source.

    I will create more combos based on this logic.

    Many Thanks for your help

  12. #12
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,821
    The SubCat Combobox is made very narrow to only display the dropdown arrow.
    Then in the after update of the Combobox there is an event that populates the Control SubCat

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by mike60smart View Post
    Hi

    The subform needs to be set as a Continuous Form vice Datasheet.
    Really Mike?
    Care to explain why? especially when MajP made this comment in this post https://www.access-programmers.co.uk...4/post-1920218

    If you went with Cascading combos to filter the Nature of Injury by an Injury Group it is not trivial to do it in a continuous form. Not super hard but does take some tricks.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,821
    Hi Welshgasman

    MajP did make the comment but in his example he shows how to use Continuous Form.

    Is he wrong as well or do you just like nit picking just me?

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    No, I am genuinely curious as to why you said that?
    My understanding is he was saying the opposite, from the quote I posted?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. specific sub-categories
    By mack7963 in forum Forms
    Replies: 2
    Last Post: 12-26-2016, 06:00 AM
  2. Report by Categories
    By studentoflife in forum Reports
    Replies: 11
    Last Post: 04-20-2016, 07:10 PM
  3. Can't Right Click Categories
    By netchie in forum Access
    Replies: 2
    Last Post: 10-26-2010, 10:48 AM
  4. Replies: 3
    Last Post: 08-29-2010, 06:34 AM
  5. Combo Box sub categories
    By workindan in forum Access
    Replies: 1
    Last Post: 06-17-2010, 09:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums