473,467 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Create 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
66 3231
NeoPa
32,556 Recognized Expert Moderator MVP
Right. The three separate threads are now set. The other two are tidy. This is a bit of a rambling mess, but nothing more I can do about that at this late stage.

DGaletar. I need you to read through the following links carefully, as your posts are causing a lot of confusion and a very great deal of wasted time for a lot of people, simply because you are not following the rules.
Before Posting (VBA or SQL) Code.
How to ask "good" questions -- READ BEFORE SUBMITTING A QUESTION!.
POSTING_GUIDELINES: Please Read Carefully Before Posting to a Forum.

After this point you will be expected to know and abide by these rules. Threads like this are likely to be deleted without preamble, regardless of how many responses are in them. If a thread is hijacked then anyone answering a hijack question must know their post is likely to be lost. Hijacking includes asking multiple questions in the same thread. If I don't sound happy, then that's because it's taken an hour of my time just organising the disparate threads (With thanks to Z who had already done part of what was a complicated job).
Jan 31 '13 #51
dgaletar
72 New Member
Good morning group. Fresh day, fresh eyes!

OK, I fixed the table name issue (sorry again for that), and ran the form. I am still getting the same error as I did in post #57:

Expand|Select|Wrap|Line Numbers
  1.                 .RowSource = zstrSQL
Any suggestions?

(here is the full code just to be safe):

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3.     Private Sub Combo14_Click()
  4.     Dim zstrSQL As String
  5.         With Me![CUA#]
  6.             If IsNull(Me!Department) Then
  7.                 .RowSource = ""
  8.             Else
  9.                 zstrSQL = "SELECT [CUA#] " & _
  10.                     "FROM [VEHICLE_DETAILS] " & _
  11.                     "WHERE [Department]=" & Me!Department
  12.     'Let us see the string
  13.                 Debug.Print "resolved string is::: " & zstrSQL
  14.                 .RowSource = zstrSQL
  15.             End If
  16.             .Requery
  17.         End With
  18.     End Sub
  19.  
You know, I was just checking the second combo box. The 'Row Source' = VEHICLE_DETAILS; and the 'Row Source Type' = Table/Query; but the 'Control Source' is empty. Does that sound right???
Feb 1 '13 #52
Seth Schrock
2,965 Recognized Expert Specialist
Both combo boxes should have the control source empty because these are unbound controls.

Also, there is no post 57, so I'm not sure what error you are getting. Just tell us the whole error message along with the number.

In line 2, place Option Explicit and then compile your code and see if you get any errors. I'm going to make a guess based on your initial screen shot that you will get an error when you do this (Link to screenshots). The screen shot shows three controls (not including labels): Select a department (which I assume has the name "Department"), "Vehicles Number" (not sure the name of the control), and a button (based on the caption, I'm going to guess that its name is Command25). In your code, the event is for a control named Combo14. Based on the information that I have, I'm going to guess that this is the combo box for the Vehicle Number. However, in line 5, your With statement is for a Me.CUA#. My guess is that these need to be the same name. If Me.CUA# doesn't exist (possibly because of multiple tries to get this to work), then you would get an error on the .RowSource because that property doesn't exist.

Compile your database with Option Explicit set and let us know the result. (To compile the database, click on the Debug menu and click Compile Database name.)
Feb 1 '13 #53
NeoPa
32,556 Recognized Expert Moderator MVP
@Dgaletar - Please check for and read my PM.
Feb 1 '13 #54
dgaletar
72 New Member
Sorry, Seth, post 47.

"The screen shot shows three controls (not including labels): Select a department (which I assume has the name "Department") [NO. THE NAME FOR THIS COMBO BOX IS Combo14], "Vehicles Number" (not sure the name of the control)[THE NAME FOR THIS COMBO BOX IS Combo26], and a button (based on the caption, I'm going to guess that its name is Command25)[NO. I REALIZED EARLY ON THAT I DID NOT NEED A BUTTON, OR AT LEAST I DON'T YET, SO I REMOVED IT.].

"In your code, the event is for a control named Combo14. Based on the information that I have, I'm going to guess that this is the combo box for the Vehicle Number." No, that is not correct. It is the Combo Box for the control labeled "Select a Department".

"However, in line 5, your With statement is for a Me.CUA#. My guess is that these need to be the same name. If Me.CUA# doesn't exist (possibly because of multiple tries to get this to work), then you would get an error on the .RowSource because that property doesn't exist." CUA# does exist in the table VEHICLE_DETAILS.
Feb 1 '13 #55
Seth Schrock
2,965 Recognized Expert Specialist
You can't reference a field in a table using the Me! command. This can only be used for controls. So based on the information that you have given me, your With statement (line 5) needs to be
Expand|Select|Wrap|Line Numbers
  1. With Me.Combo26
Did you set Option Explicit and compile your code? What was the result?

I would also highly recommend renaming your controls so that they mean something. You can search online for Access naming conventions. It will really help you.
Feb 1 '13 #56
zmbd
5,501 Recognized Expert Moderator Expert
see my post - do as asked.
line12 - post that resolved string as asked
Feb 1 '13 #57
Seth Schrock
2,965 Recognized Expert Specialist
I think we got the SQL portion figured out Z. Starting with Post #4 ending with post #33 we got the results that were needed. The issue now seems to be with control names, which I must admit, are very confusing. Evidentally, CUA# is only a field and not a control so it doesn't have a .RowSource property. So the error coming from
Expand|Select|Wrap|Line Numbers
  1. .RowSource = zstrSQL
is coming from the .RowSource side and not the zstrSQL side.

However, I would encourage dgaletar to follow instructions.
Feb 1 '13 #58
zmbd
5,501 Recognized Expert Moderator Expert
@ Seth,
Disagreed.
- You asked OP to do as I'd asked in post #49 - although I forgot to include the Option explicit... busy day, I was/am fairly rushed at work this month.

- OP post #47 clearly states that there is still an error occuring. We're only guessing at the SQL.....

- .... your questions are still picking and poking at that SQL string, which when posted would give you some better tools to work with.

- OP still is not providing the EXACT title, error number, and error text/description.

Failing to provide requested information is worse than useless, it wastes what little time all of have to help. I have between 5 and 10 minutes at work between tests and at home between 4 children and a wife and other responsibilities to provide some help - failing to provide the requested information steals the time from someone else's question.
Feb 1 '13 #59
dgaletar
72 New Member
OK, I get it! I'm a BAD BAD man!!! Sorry, but this is all pretty confusing to me. I'm doing the best that I can!

I didn't give you the information that you asked for in post#49 because you also gave me a task to do. I had no idea how to do that so it took me a while to figure it out. When I returned, Seth had posted another response and I went on to that.

I imagine that I won't be in this forum much longer anyway. But until NeOpa get his hands on me, would you please ask a specific question and I will give you an specific response as fast as I can.
Feb 1 '13 #60
Seth Schrock
2,965 Recognized Expert Specialist
1. Get Z the string that got printed in the immediate window
2. Set Option Explicit in line 2 of your code
3. Compile your database and fix the errors. If you need help, then possibly a new thread might be in order for just that question.
Feb 1 '13 #61
dgaletar
72 New Member
OK, right now, when I execute the form I get the following Microsoft Visual Basic for Applicati... error box: Compile error; Syntax error. Line 1 (Private Sub Combo14_Click()) is highlighted in yellow, and line 7 ( zstrSQL = "SELECT [CUA#] " &) is highlighted in blue.
Feb 1 '13 #62
dgaletar
72 New Member
Sorry, I posted that before I saw your post.

1. From the immediate window:

Expand|Select|Wrap|Line Numbers
  1. resolved string is::: SELECT [CUA#] FROM [VEHICLE_DETAILS] WHERE [Department]=4
2. I put "Option Explicit" in line 2 of the VBA code and moved "Dim zstrSQL As String" to line 3. I got another compile error: "Invalid inside procedure".

3. I have to google "Compile you database" so it may take ma a while.
Feb 1 '13 #63
Seth Schrock
2,965 Recognized Expert Specialist
To compile your database, you just need to click on the Debug menu in the VBA editor and click Compile your database name.

Sorry, by line 2, I was meaning line 2 of what you posted in post 52. It should go right below the Option Compare Database. So at this point, your code should look like this:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4.     Private Sub Combo14_Click()
  5.     Dim zstrSQL As String
  6.         With Me![CUA#]
  7.             If IsNull(Me!Department) Then
  8.                 .RowSource = ""
  9.             Else
  10.                 zstrSQL = "SELECT [CUA#] " & _
  11.                     "FROM [VEHICLE_DETAILS] " & _
  12.                     "WHERE [Department]=" & Me!Department
  13.     'Let us see the string
  14.                 Debug.Print "resolved string is::: " & zstrSQL
  15.                 .RowSource = zstrSQL
  16.             End If
  17.             .Requery
  18.         End With
  19.     End Sub
  20.  
Once you have compiled your database with out getting any errors, try replacing line 6 with
Expand|Select|Wrap|Line Numbers
  1. With Me.Combo26
Feb 1 '13 #64
dgaletar
72 New Member
Thank you again, Seth, for continuing to help me through this.

I did as you said first, clicked on "Compile" under "Debug" and selected my database but nothing happened.

So I switched line 6 code like suggested and...

IT WORKS!!!

You did it Seth!!! Thank you sooooo much!

I'll have to figure out how to open the corresponding form from here, but THANK YOU!!!
Feb 1 '13 #65
Seth Schrock
2,965 Recognized Expert Specialist
Glad to be able to help!

A quick nudge for your other problem, Google DoCmd.OpenForm and DoCmd.SearchForRecord. If you need any futher help with that, just start a new thread since that is a new problem.
Feb 1 '13 #66
dgaletar
72 New Member
Awesome! Thanks bud!

Somehow that was as easy as 1, 2, 3! Thanks!
Feb 1 '13 #67

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

Similar topics

0
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 ...
0
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...
4
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...
3
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...
4
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...
3
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...
7
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...
8
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...
3
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...
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
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,...
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
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
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...
1
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
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
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...
0
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 ...

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.