By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,857 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

Dropdown Boxes

rcollins
100+
P: 234
I have 2 dropdown boxes on my form, both which pull from table I made for each. First I select the Service that I want, then I want the Service Type to be limited to the types only with the Service ID that matches the ID from the first box. How do I implement this?
Dec 19 '06 #1
Share this Question
Share on Google+
10 Replies


100+
P: 106
I have 2 dropdown boxes on my form, both which pull from table I made for each. First I select the Service that I want, then I want the Service Type to be limited to the types only with the Service ID that matches the ID from the first box. How do I implement this?
Try something like this behind your combo box's row source
Expand|Select|Wrap|Line Numbers
  1. SELECT table.servicetype FROM table table.service HAVING (((table.service)=forms!YourformName!Sevice-Combobox-name)); 
  2.  
Dec 19 '06 #2

rcollins
100+
P: 234
SELECT table.tblServiceType FROM table table.tblService HAVING (((table.tblService)=forms!frmMain!Combo24));
I think i changed this right. Here are the names I am using for the different items:
Tables are
tblService
tblServicetype
Form is
frmMain
Combo box is
Combo24
this is not an extensive database, this shouldnt be to hard to do. When I modified what you gave me, I have nothing in the Service type box
Dec 20 '06 #3

missinglinq
Expert 2.5K+
P: 3,532
This concept is called Cascading Comboboxes. Here's a fairly good explanation and example code:

http://www.mvps.org/access/forms/frm0028.htm
Dec 20 '06 #4

rcollins
100+
P: 234
Very good example. The only problem is that now I have the ID showing in the second dropdown, not hte ServiceType.
Dec 20 '06 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Very good example. The only problem is that now I have the ID showing in the second dropdown, not hte ServiceType.
You need to change the column widths property to hide the ID and make sure your column count = 2.

Column Count 2
Column Widths 0cm; 3cm (For example)

Mary
Dec 21 '06 #6

rcollins
100+
P: 234
Here is what I have done, Now it doesn't work at all.
From the website sent to in previous post
Private Sub Combo24_AfterUpdate()
Dim strSQL As String
strSQL = "Select " & Me!Combo24
strSQL = strSQL & " from Categories"
Me!Combo46.RowSourceType = "Table/Query"
Me!Combo46.RowSource = strSQL
End Sub
Combo24 is my first box and 46 my second
Then put this in row source of Combo46
Select ServiceIDID, Service from tblService Where ServiceID= Forms!frmMain!Combo24;
Then in after update of Combo 24 put
Private Sub Combo24_AfterUpdate()
Me!Combo46.Requery
End Sub
This isnn't working. Contact by email if easier, I am supposed to have this database finished today and this is all that is left. Thanks for helping. rcollins@mds.acsol.net
Dec 21 '06 #7

MMcCarthy
Expert Mod 10K+
P: 14,534
Expand|Select|Wrap|Line Numbers
  1.    strSQL = "Select " & Me!Combo24
  2.    strSQL = strSQL & " from Categories"
  3.     Me!Combo46.RowSourceType = "Table/Query"
  4.     Me!Combo46.RowSource = strSQL
  5.  
This doesn't make sense. Me!Combo24 is a value not a field name. You can't select a value from a Table

Mary
Dec 21 '06 #8

rcollins
100+
P: 234
Thank you for your responce. I actually had to change some things in my database, but I got it to work following an examlpe that I found online. Thanks
Dec 21 '06 #9

MMcCarthy
Expert Mod 10K+
P: 14,534
Thank you for your responce. I actually had to change some things in my database, but I got it to work following an examlpe that I found online. Thanks
No problem

I'm glad you got it working

Merry Christmas

Mary
Dec 21 '06 #10

rcollins
100+
P: 234
So here I go again, on a different database. I have a form and subform where I input client names and the employers that they work for, frmClientJob and frmClientJobs Subform. I have a dropdown box called Employer that pulls the employer name from tblEmployer, the I have a table tblEmployerJobs where I have what jobs each employer has. I want the Employer dropdown to only have the jobs that go to the employer that is picked from the employer dropdown. Last time I did this in the other database, I had seperated the info to different tables, then had it show just the info in the specific table.I can not do that here, because the table information changes. Can you help me?
Jun 5 '07 #11

Post your reply

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