473,792 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 07 ComboBox Filter results category subcategory type SubType

gcoaster
117 New Member
Hello Everyone!

I have a question regarding "cascading combobox(s) list(s)"

I would like:

ComboBox 2 to show results from ComboBox 1's selection,
then ComboBox 4 to show results from ComboBox 3's choice

For Instance these are the combo boxes
[category] [subcategory] [type] [subtype]

This is the sample of choices in the combo boxes
HARDWARE - CABLES - USB - 2.0
HARDWARE - CPU - AMD - AM2

QUESTION(s)

Do I create ONE table for this? OR
Do I create 4 tables = tblcategory tblsubcategory tbltype tblsubtype ?
Do I place a QUERY in the middle of the TABLE(s) and the FORM?

Should I use VBA to make this work?
Should I use sql in the control source to make this work?

What is the best solution? so many answers, so many posts,..
a lookup in a table field.

thank you in advanced!!!

Matt
Oct 4 '07
34 12607
gcoaster
117 New Member
FishVal, you rock..
I am going to print this out, go to the coffee house.. come back and try it!
thank you FishVal.
you ever on the gold coast of Australia let me know!

M@
Oct 5 '07 #11
gcoaster
117 New Member
NeoPal, thank you! every little bit counts..

one comment, that is some SERIOUS VBA!!!!

being the newbie I am, I was getting errors with what i copied and pasted from FishVAl and at 2am in the morning i was just ready to just use a WAMP in a VMWARE machine and switch over to MySQL using MyPhpAdmin and php w/ XTHML + CSS with a pretty web2.0 interface and maybe some spry.. using dreamweaver and Adobe Dreamweaver Developer Toolbox,

( yea that sounds complex but i am finding the comboboxes in access hurt my brain more! HAHA )

I CANNOT imagine debugging the fallowing until i learn the basics.
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub txtFindAccountCode_AfterUpdate()
  5.     Call CheckFilter
  6. End Sub
  7.  
  8. Private Sub txtFindCreationDate_AfterUpdate()
  9.     Me!txtFindCreationDate = IIf(IsDate(Me!txtFindCreationDate), _
  10.                                  Format(Me!txtFindCreationDate, "d mmm yyyy"), _
  11.                                  "")
  12.     Call CheckFilter
  13. End Sub
  14.  
  15. Private Sub cboFindAccountType_AfterUpdate()
  16.     Call CheckFilter
  17. End Sub
  18.  
  19. 'CheckFilter produces the new Filter depending on the values currently in
  20. 'txtFindAccountCode, txtFindCreationDate & cboFindAccountType.
  21. Private Sub CheckFilter()
  22.     Dim strFilter As String, strOldFilter As String
  23.  
  24.     strOldFilter = Me.Filter
  25.     'txtFindAccountCode - Text
  26.     If Me!txtFindAccountCode > "" Then _
  27.         strFilter = strFilter & _
  28.                     " AND ([AccountCode] Like '" & _
  29.                     Me!txtFindAccountCode & "*')"
  30.     'txtFindCreationDate - Date
  31.     If Me!txtFindCreationDate > "" Then _
  32.         strFilter = strFilter & _
  33.                     " AND ([CreationDate]=" & _
  34.                     Format(CDate(Me!txtFindCreationDate), _
  35.                            "\#m/d/yyyy\#") & ")"
  36.     'cboFindAccountType - Numeric
  37.     If Me!cboFindAccountType > "" Then _
  38.         strFilter = strFilter & _
  39.                     " AND ([AccountType]=" & _
  40.                     Me!cboFindAccountType & ")"
  41.     'Debug.Print ".Filter = '" & strOldFilter & "' - ";
  42.     'Debug.Print "strFilter = '" & strFilter & " '"
  43.     'Tidy up results and apply IF NECESSARY
  44.     If strFilter > "" Then strFilter = Mid(strFilter, 6)
  45.     If strFilter <> strOldFilter Then
  46.         Me.Filter = strFilter
  47.         Me.FilterOn = (strFilter > "")
  48.     End If
  49. End Sub
Oct 5 '07 #12
NeoPa
32,579 Recognized Expert Moderator MVP
Gold,

I suggest you put your actual project aside for a bit while you progress through this article. It's a bit like a tutorial and includes the database to download.
If you have trouble with it or specific questions, I can help. I expect once you start to go through it it will start to make better sense.
Oct 5 '07 #13
gcoaster
117 New Member
Hello NeoPa,
thank you for offering to help. You are a scholar and a gentleman

It doesn't look that bad, I just may read and study.. just noticed like in CSS the
lines that start with a ' is a comment */ comment */ so there is not as much code as i thought.
One thing, It is 2007, things are going FAST.. guys like me DONT HAVE TIME, especially trying to debug code and it ends up being a comment out of place. then you have to search for help on the obscure ms error message.

Trying to stay ahead of the game is almost information overload, you miss a beat and your behind, I have learned to KEEP IT SIMPLE
you get IN and you get OUT.

I could and actually will spend another 2 days figuring this out, then I get it done.. enter data and don't dive into the code again till i want to customize it or something isn't right..

this is one reason allot of people use FileMaker, they get frustrated with access and filemaker you get in and get out. but once your in your in!

by the way, i did have my doubts with going with access 07, there is not a access 2007 export to MySQL yet, but you can always make table etc etc.

anyways, thank you all!

Matt
Oct 5 '07 #14
gcoaster
117 New Member
Hello FishVal,

I need your help please, I think I am close.
I keep getting an error.. here is the code
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmboMainCategory_AfterUpdate()
  4.     With Me!cmboSubCategory
  5.         If IsNull(Me!cmboMainCategory) Then
  6.             .RowSource = ""
  7.         Else
  8.             .RowSource = "SELECT keyCategoryID,txtCategoryName" & _
  9.                  "FROM @CATEGORY" & _
  10.                  "WHERE keyParentCategory=" & Me!cmboMainCategory & ";"
  11.             End If
  12.             Call .Requery
  13.     End With
  14. End Sub
-- what am i doing wrong?! thank you
Oct 6 '07 #15
FishVal
2,653 Recognized Expert Specialist
Hello FishVal,

I need your help please, I think I am close.
I keep getting an error.. here is the code

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmboMainCategory_AfterUpdate()
  4.     With Me!cmboSubCategory
  5.         If IsNull(Me!cmboMainCategory) Then
  6.             .RowSource = ""
  7.         Else
  8.             .RowSource = "SELECT keyCategoryID,txtCategoryName" & _
  9.                  "FROM @CATEGORY" & _
  10.                  "WHERE keyParentCategory=" & Me!cmboMainCategory & ";"
  11.             End If
  12.             Call .Requery
  13.     End With
  14. End Sub
  15.  
-- what am i doing wrong?! thank you
Hi, Matt.

The code seems to be Ok.
  • what error are you getting? where code execution stops?
  • what are the settings of [cmboMainCategor y] and [cmboSubCategory] properties ?
    • ColumnCount
    • BoundColumn
    • RowSource
  • did you try to execute RowSource statement in query builder?
Oct 6 '07 #16
gcoaster
117 New Member
Hello FishVal

Here is what I have

Table
@CATEGORY

Columns in @CATEGORY Table
mainCategoryID
name
keyCategoryID

Combo Boxes
cmboMainCategor y
cmboSubCategory

Expand|Select|Wrap|Line Numbers
  1. Properties of Combo Boxes
  2.     cmboSubCategory
  3.         Control Source       | softCategory ( tried nothing as well )
  4.         Row Source            | @CATEGORY
  5.         Bound Column       | tried everything 1 2 3 
  6.         Count                       | 2
  7.         Widths                     | 0cm;1cm 
  8.  
  9.     cmboSubCategory
  10.         Control Source       | softSubCategory ( tried nothing as well )
  11.         Row Source            | @CATEGORY
  12.         Bound Column       | tried everything 1 2 3 
  13.         Count                       | 2
  14.         Widths                     | 0cm;1cm
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmboMainCategory_AfterUpdate()
  2.     With Me![cmboSubCategory]
  3.         If IsNull(Me!cmboCategory) Then
  4.             .RowSource = ""
  5.         Else
  6.            .RowSource = "SELECT MaincategoryID, name" & _
  7.                         "FROM @CATEGORY " & _
  8.                         "WHERE [keyCategoryID]=" & Me!cmboMainCategory
  9.         End If
  10.         Call .Requery
  11.     End With
  12. End Sub
Matts hair… -handfull per 2 errors and no results

Question: If I ever get this working.. then how do I add the next 2?
Type and then Sub Type?
thank you FishVal
Oct 6 '07 #17
FishVal
2,653 Recognized Expert Specialist
Hi, Matt.

See the attached example.
Attached Files
File Type: zip 4CascadeCombos.zip (13.3 KB, 291 views)
Oct 6 '07 #18
NeoPa
32,579 Recognized Expert Moderator MVP
Hello FishVal,

I need your help please, I think I am close.
I keep getting an error.. here is the code
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmboMainCategory_AfterUpdate()
  4.     With Me!cmboSubCategory
  5.         If IsNull(Me!cmboMainCategory) Then
  6.             .RowSource = ""
  7.         Else
  8.             .RowSource = "SELECT keyCategoryID,txtCategoryName" & _
  9.                  "FROM @CATEGORY" & _
  10.                  "WHERE keyParentCategory=" & Me!cmboMainCategory & ";"
  11.             End If
  12.             Call .Requery
  13.     End With
  14. End Sub
-- what am i doing wrong?! thank you
No space before the FROM (or the WHERE for that matter).

@Gold Please notice that two of your posts now have the edit comment (Please use [code] tags).
This is because everything works so much better when you can read what's being posted. I'm sure Fish would have seen the missing space if it had been laid out clearly.

*edit* I just noticed a later post indicating you're obviously trying. Look at the (#) button when creating or editing your post and read the text at the right on the "New Post" page for hints :)
Oct 6 '07 #19
NeoPa
32,579 Recognized Expert Moderator MVP
If you examine the .RowSource property after it's been set up - you'll easily see what I mean ;)
Oct 6 '07 #20

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

Similar topics

5
3385
by: Travis Pupkin | last post by:
Hey, I've done a number of product catalogs/galleries with one or two category levels (Category > Subcategory). The straightforward way to do this, of course, is to use database fields for Category and Subcategory and query off of those fields. I have a client now who is interested in what sounds to me to be an unnecessarily complex catalog with an as of yet undefined number of category levels at their disposal.
3
4618
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 categories contain subcategories AA, AB, AC, AD,...AJ, BA, BB...BJ, CA, CB, CC...CJ, etc in fld2. I am counting how many subcategories are listed for each category. Like
1
306
by: A.J.M. van Rijthoven | last post by:
I have a form with data from a box (Table box), on his form is a subform with the instuments that are in this box. The instruments (Table instruments) are categorized by category (Table Category). This is done because there are a verry much different instruments to choose from. Now I want to choose a category so that the active record in the subtable (combobox) shows only the instruments that belong to the selected category. This works...
9
4325
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access application as the data source, and then performs a merge. Everything works fine. However, when a user uses it in Access 2002 and Word 2002, an extra instance of the Access application is opened and remains open at the end. Sometimes it remains open
0
982
by: Ron | last post by:
I am trying to create a nested DataList with multiple subcategories listed under each primary category. Unfortunately, I end up with a bunch of multiple SubCategory values after iterating through the loop. My code is as follows: //**************************************************************** for(int i=0;i<=cat.Count-1;i++) {
1
1498
by: bobika | last post by:
Hi Im am implementing a small database system using MS Access. I have two main fields: :product category and product type! Product category contains ABC and XYZ categories. I added both in the combobox selection just fine. In category ABC it contains several product types say NB and DT In cateogfry XYZ it contains different product types say HTand HP. I made both fields (product type and category) comboboxes. my problem is that when the...
1
2801
by: Webstorm | last post by:
Hi, I hope someone can help me sort this out a bit, Im completely lost. Here is the page I am working on: http://www.knzbusinessbrokers.com/default.asp I have 3 search critera that I need to use when querying the database. Right now it is only looking for a match on one of those dropdowns and not all 3. can anyone help? Here is the code: <form BOTID="0" METHOD="POST" action="businessforsale_interface/Results/test3.asp">
1
2362
by: Brit | last post by:
I have an ASP file that retrieves names from an Access database for 4 different categories of membership, which the visitor to the page selects (corporate, institutional, regular, or student). The DNS name is "cati", the names are specified in the "Last_names" field, and the categories are in the "categories" field. l want the results sorted in alphabetic order by last name. However, the results appear to be in a totally random,...
3
1415
by: jillinsky | last post by:
Wondering is this is possible - I have 2 tables. One is categories, and has catid, catname, hashighercat, and ...I can't think of the 4th one, but it isn't needed anyway. There are 40 categories, and about 1400 subcats. the categories are numbered 1-40, and the rest have their numbers - all of these are in the same field - catid. You can tell the categories from the subcategories by the field hashighercat - the 40 categories are null...
0
9518
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4111
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 we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.