473,669 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cascading Combo Box Filtering

dgaletar
72 New Member
{Moderator Edit}
I have moved this hijack post to a new thread. Please do not take over an existing thread with your own questions as this is a punishable offense.
The original thread, from where this was originally taken, can be found at how to filter list of items in a combo box by selecting items in another combo.
{/Moderator Edit}
OK, I changed the FROM statement, and am still getting flagged. Now the ".RowSource " & the "FROM" lines have red dots, and the "WHERE" has a red dot with a yellow arrow.

Does that make sense???

Also, when I hover the mouse anywhere over those three lines, a message (sort of a help tip) appears below the mouse. It says: Me!Department=4.
Jan 31 '13 #1
66 3285
Seth Schrock
2,965 Recognized Expert Specialist
The code in your screenshot1 doesn't match the code you provided in post #4. Please post what you have using Copy/Paste (and please use code tags, the [CODE/] button) so that we can see exactly what you are working with.

What I'm seeing in the screenshot is that your SQL code selects [Combo26] from your table. My guess is that there isn't a field called Combo26, which would cause an error.
Jan 31 '13 #2
dgaletar
72 New Member
Sorry about that! I changed it after I found that [Combo26] was incorrect.

Here is the code as I am using it now:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo14_Click()
  2.         With Me![CUA#]
  3.             If IsNull(Me!Department) Then
  4.                 .RowSource = ""
  5.             Else
  6.                 .RowSource = "SELECT [CUA#] " & _
  7.                              "FROM [VEHICLE DETAILS : Table] " & _
  8.                              "WHERE [CUA#]=" & Me!Department
  9.             End If
  10.             Call .Requery
  11.         End With
  12. End Sub
I also noticed that in Rabbits article he used this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Company_AfterUpdate()
instead of:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo14_Click()
...with me changing "Company" to "Department ".

But, when I tried to execute the command, the dropdown box didn't work.

Then, when I went back into the design mode, the [EventProcedure] was gone from the "OnClick" line. When I clicked on the three dots, it started from scratch, starting a new "Private Sub" with the line "Combo14_Click( )" in it.
Jan 31 '13 #3
Seth Schrock
2,965 Recognized Expert Specialist
Just for troubleshooting purposes, lets assign your SQL code to a variable.
Expand|Select|Wrap|Line Numbers
  1. Dim strSql as String
  2. strSql = "SELECT [CUA#] " & _
  3. "FROM [VEHICLE DETAILS : Table] " & _
  4. "WHERE [CUA#]=" & Me!Department
  5.  
  6. Debug.Print strSql
  7. .RowSource = strSql
Replace your lines 6-8 with the above code, make sure your immediate window is open (Ctrl + G will open it if not), and then run your code. Copy and paste what is printed in the immediate window into a new query and run it. If the results are what you expect, then the problem isn't with your SQL and is somewhere else. I'll continue to look for that something else, but will wait to post any ideas until after you respond with the results.
Jan 31 '13 #4
dgaletar
72 New Member
I am soooo sorry Seth Schrock, but this is wayyyy over my head! I coppied and pasted the code that you listed into mine and now I have this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Department_AfterUpdate()
  2. 'Private Sub Combo14_Click()
  3.         With Me![CUA#]
  4.             If IsNull(Me!Department) Then
  5.                 .RowSource = ""
  6.             Else
  7. '                .RowSource = "SELECT [CUA#] " & _
  8. '                             "FROM [VEHICLE DETAILS : Table] " & _
  9. '                             "WHERE [CUA#]=" & Me!Department
  10.     Dim strSql As String
  11.     strSql = "SELECT [CUA#] " & _
  12.     "FROM [VEHICLE DETAILS : Table] " & _
  13.     "WHERE [CUA#]=" & Me!Department
  14.  
  15.     Debug.Print strSql
  16.     .RowSource = strSql
  17.  
  18.  
  19.             End If
  20.             Call .Requery
  21.         End With
  22. End Sub
  23.  
I then did Ctrl+G and opened the "immediate window".

"run your code"... I pressed the green arrow and a Macros box popped up asking me for the Macro name. I of course have not named any of my macros (as I do not know how to, or that I am supposed to), so I typed in "Department " as a name and hit create. It opened a new box labeled "Vehicles - Module1 (Code)". I copied and pasted all of the code into this new box and it looks like this:

Expand|Select|Wrap|Line Numbers
  1. Sub Department()
  2. Private Sub Department_AfterUpdate()
  3. 'Private Sub Combo14_Click()
  4.         With Me![CUA#]
  5.             If IsNull(Me!Department) Then
  6.                 .RowSource = ""
  7.             Else
  8. '                .RowSource = "SELECT [CUA#] " & _
  9. '                             "FROM [VEHICLE DETAILS : Table] " & _
  10. '                             "WHERE [CUA#]=" & Me!Department
  11.     Dim strSql As String
  12.     strSql = "SELECT [CUA#] " & _
  13.     "FROM [VEHICLE DETAILS : Table] " & _
  14.     "WHERE [CUA#]=" & Me!Department
  15.  
  16.     Debug.Print strSql
  17.     .RowSource = strSql
  18.  
  19.  
  20.             End If
  21.             Call .Requery
  22.         End With
  23. End Sub
  24.  
  25. End Sub
Now when I click on the green arrow I get an error message saying "Compile Error: Expected End Sub". If I remove that line from the code and click on the green arrow, I get another error message that says "Compile error - Invalid Use of Me keyword", and the "Private Sub Department_Afte rUpdate()" turns yellow.

I feel like an idiot!!! What am I doing wrong?
Jan 31 '13 #5
Seth Schrock
2,965 Recognized Expert Specialist
Don't worry, you aren't an idiot. It wasn't that long ago that I was running into the same types of problems.

To run your code, you need to perform the action that triggers the event. In this case, you need to change the value selected in the Department combo box. That will trigger the Department's AfterUpdate event and run your code.
Jan 31 '13 #6
zmbd
5,501 Recognized Expert Moderator Expert
I've split this entire series out of the original thread they were posted because this was technically a Hijack. Honestly, I'm surprised it was allowed to continue.

However, at this point, the information and the help certainly merited its own thread instead of being deleted.

Dgaletar: Please in the future do not Hijack other people's threads, even though it is the same or close to the same topic. Instead, please post your own thread. It is usually permissible to provide a link(s) to the thread(s) that have a direct relationship to your question.
Jan 31 '13 #7
dgaletar
72 New Member
OK zmbd, thanks. It won't happen again.

And Seth Schrock, thanks for understanding!

OK, So I ran the code again with the immediate window open. First off, I had to change that first line from "Private Sub Company_AfterUp date()" to "Private Sub Combo14_Click() " for it to run at all.

Then, when I did run it, I got an error popup - Microsoft Visual Basic - Runtime error '438': Object doesn't support this property or method.

But, in the immediate window I got this: SELECT [CUA#] FROM [VEHICLE DETAILS : Table] WHERE [CUA#]=4.
Jan 31 '13 #8
Seth Schrock
2,965 Recognized Expert Specialist
Okay. If you click Debug on the error message, which line does it highlight?

Take what you got in the immediate window, create a new query object and paste that into the SQL view and try to run it. Let me know the results.
Jan 31 '13 #9
dgaletar
72 New Member
Expand|Select|Wrap|Line Numbers
  1.     .RowSource = strSql
is highlighted.

Okay, never did this before so bear with me...

I clicked on "Create", and then "Query Design". I closed the "Show Table" box and clicked on the "SQL" view in the top left hand corner. I pasted that line of code and got this error message:

"The Microsoft Access database engine cannot find the input table or query 'VEHICLE DETAILS : Table"'. Make sure it exists and that it's name is spelled correctly."
Jan 31 '13 #10

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

Similar topics

0
2071
by: cognoscento | last post by:
I'm currently putting together a database for my work (not an expert by any stretch, so muddling through as best as I can... you know the story...) and I could use some advice and hand-holding I've got a subform with a series of cascading combo boxes (thanks to the Access tutorials on fontstuff.com) that let the user assign categories to items, in this case photos. This is being done to help constrain user selections and keep the...
0
1247
by: visionstate | last post by:
Hi All, I have a few tiny problems left with my cascading combo boxes. Here is what my form looks like: http://img219.imageshack.us/my.php?image=databaseformwl5.png The way it works is by filtering by previous entries. So for instance, if I Choose Admin from the Department then I get the selection of teams from that Department. When I choose a Team, I get the list of Surnames from that Team and so forth.
4
64590
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one determines the available options in the other. TERMINOLOGY Row Source: The table/query from which the Combo Box or List Box gets its values. Note: There are other types of row sources that can be used but for simplicity we will stick with Tables...
3
3694
by: buddyr | last post by:
Hello, Yesterday I recieved help with two cascading combo boxes on an access form. I went the link http://www.fontstuff.com/access/acctut10.htm And basically used their first example. Now I may need 3 cascading combo boxes and I cannot figure out how to do that. Can you help? Thank you
4
3484
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields below. tblOrg OrgID, AutoNumber, PK ZipID, Number, FK tblState StateID, AutoNumber, PK
3
3976
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment list will 'display in the drop down list of CboSegment With Me! If IsNull(Me!cboDivision) Then
7
5828
by: Toireasa | last post by:
Hi, Newbie Access developer here, and my first post on this forum, so I might not get everything right - thanks in advance for your help and your patience! I'm using Access 2007, in XP. I'm currently trying to set up a whole pile of cascading combo boxes of different levels of complexity, so I started with the easiest set - and can't even get that to work (even using the tutorial on this site at...
8
9296
by: 20028431 | last post by:
This is driving me mad! I have been trying for 3 days now to work out how to do this with no success. I have tables for Customer, Bookings, Entertainment, Act, Agent, and several others. I have created a form to view existing bookings with Customer details as mainform and Bookings and Entertainment as subforms and this works fine. I am trying to create forms to allow the booking clerk to enter a new Booking and am looking to have a...
3
2609
by: MOCaseA | last post by:
I have a record lookup form that has several combo box filters set up. However I noticed a slight problem. The filters are working correctly, but there are now over 2000 entries and when filtering there are too many possible selection even with other filters applied. Example 1: POC Doe, John wants to look up a record he created on 01/01/2010. He selects his name and after updating he accidentally selects 01/02/2010 (despite that fact that...
0
8465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8895
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
7407
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
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
5682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
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...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2797
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
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.