I have two combo boxes, combo1 and combo2. Combo1 has all of the different employers that our clients work for. Cobo2 has the job descriptions that each of the employers have. On the form, I want to be able to pick an emplyer from combo1 then have combo2 only show what corrosponds with combo1. I have done this once with seperate tables for the different values in the table for combo1, but since there are always employers and job descriptions being added, it won't work this way. Any suggestions?
7 1383
So I followed the instructions, they sound pretty simple, but all I get in the second dropdown is an empty list. Here is what I have, am I missing something?
My two comboboxes are called Employer and JobDescription. -
-
tblEmployer
-
[ID] - AutoNNumber, PK
-
[Name] - Text, Name of Employer
-
-
tblEmployerJobs
-
[JobTitle] - Text, Description of Job
-
[EmployerID] - FK, Used to link Job to Employer
-
[ID] - AutoNumber, PK
-
-
Private Sub Employer_AfterUpdate()
-
With Me![JobDescription]
-
If IsNull(Me!Employer) Then
-
.RowSource = ""
-
Else
-
.RowSource = "SELECT [JobTitle] " & _
-
"FROM tblEmployerJobs " & _
-
"WHERE [ID]=" & Me!Employer
-
End If
-
Call .Requery
-
End With
-
End Sub
-
Hi. You are referring to the wrong ID field in your WHERE clause (at line 17 above). The ID you specified is the autonumber of tblEmployerJobs instead of the employer FK. Revised version below.
It was very helpful to include the details of the two tables in your code, otherwise this would have been hard to spot - well done! -
"WHERE [EmployerID]=" & Me!Employer
-
-Stewart
Still nothing -
Private Sub Employer_AfterUpdate()
-
With Me![JobDescription]
-
If IsNull(Me!Employer) Then
-
.RowSource = ""
-
Else
-
.RowSource = "SELECT [JobTitle] " & _
-
"FROM tblEmployerJobs " & _
-
"WHERE [EmployerID]=" & Me!Employer
-
End If
-
Call .Requery
-
End With
-
End Sub
-
Hi again. 'Still nothing' does not help me (or anyone else) at the other end of a web connection to help you! You will need to do some systematic debugging now that the original error is, presumably, cleared, because we cannot know what else could be wrong unless you tell us the state values of the variables involved.
You could set a breakpoint in your code and step through each line, using the local variable window to watch the values of the variables as you go.
You could also check what the rowsource is actually being set to by outputting its value using a messagebox, placing the following line before your End WIth: - msgbox "Rowsource = " & .rowsource
If you find that an employer ID is being provided check that it matches a row in the table. If it doesn't there is a problem with setting the employer control value.
This will give us more of a concrete nature to go on than we have at present.
-Stewart
Sorry about the no info on Friday, Get braindead by the end of the week. I put the message box like you sugested and I get the value ok from the employer dropdown. But isnt the msgbox "Rowsource = " & .rowsource supposed to give me the JobDescription value? The JobDescription box still shows empty. I tried using breakpoints and am not getting any info from it. I hope this is enough for you.
Hi again. The messagebox should display something like this:
Rowsource = SELECT [JobTitle] FROM tblEmployerJobs WHERE [EmployerID]= 12345
What is being tested is that, firstly, the SQL is OK (as it certainly looks OK in the after-update code), and, secondly, that there is a numeric value for the employer ID. If that numeric ID corresponds to one of the records in your job description table there should be no problem with the job description combo - in which case you could manually paste the SQL code into the SQL view of the query editor to check that it does return records. If it does so in the query editor but not in your combo then the width setting of the combo column is suspect (set a value of 5cm (2in), say, to make sure you will see values in the combo).
If none of this helps you could zip a sanitised copy of your database to your next post for us to check. If that is not possible (for confidentiality or other reasons) I'd be glad to assist by checking your database on your behalf in confidence. Should that be an option you wish to explore just let me know by sending a PM and I will send my e-mail address on to you.
Cheers
Stewart
PS the rowsource for a combo box is normally a table or query, not a value list. It is the execution of the query which returns the data listed in the combo (similarly for listboxes). It is the ability to change the query on the fly which is exploited when cascading listboxes.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kathy |
last post by:
In my custom menu one menu item opens a form to add new Makes to TblMakes and
another menu item opens a form to add new Models to TblModels. I have a form
that has a combobox for Makes and a...
|
by: johnson_cy |
last post by:
I am using Access 2000.
My main form has a record source of a table (employeeTbl with key of
. It is filtering the record results.
My subform and mainform have the link child/link master set...
|
by: Craig G |
last post by:
for months we have been dabling round looking at various 3rd party
comboboxes that allow the user to type text into the combobox as a search
mechanism
what we've found is that the likes of...
|
by: Marcin Podle¶ny |
last post by:
Hi,
I've a form with three comboboxes. Each of them contains the same data - all
cities in my country. As you see it's a lot of data so it takes a lot of
memory. I'd like to use the same...
|
by: Sam |
last post by:
Hi,
I have a datagrid which has (amongst other stuff) 2 comboboxes columns.
So far so good. The trick is that when I select a value in my first
column, it must updates the items of the combobox in...
|
by: ashishtarlekar |
last post by:
Hi all,
I have to add comboboxes in the first row of datagridview for
mapping the database fields.
For e.g. I have to show Id, FirstName, LastName in each comboboxes in
the first row. if i select...
|
by: Matt |
last post by:
Hi all, me again! :)
I've now got an issue with combo boxes. Basically, I have a number of
items that I want a user to pick from a single list. It's basically
along the lines of:
Fruit 1: ...
|
by: Randy |
last post by:
I have a routine that creates a series of comboboxes, each of which is
bound to a common dataview. Everything used to work fine, but now,
when I change the value of any of the comboboxes, the...
|
by: Anthony Bollinger |
last post by:
I have two tables in a master-detail relationship. When I make a selection
in one combobox, how do I have it display the values from a second combobox?
Each table has a key and a text value for...
|
by: Wingot |
last post by:
Hey,
I have a view to a database that I have created for Client Maintenance. It has
a number of fields, but the important ones are Medical Condition, Bill To, and
Country.
I have a couple of...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |