473,486 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combo Boxes

10 New Member
I'm new to this forum as well as Access 2003 and I have tried to read through some of the posts in relation to my question, but I need a more thorough understanding.

I have 4 combo boxes that I want to populate the values no matter which one the end user starts with-- cbo_Dept, cbo_Boat, cbo_Type, cbo_POC-total records 10,000. For the POC I used a query for my values instead of values from my main table because a POC can have more than one occurence of the other 3 values and I only wanted to list each name once. How can I point back to the main table for the other values to populate based on the selection from the query of POC and then vice versa if they don't start with the POC?
Jul 30 '07 #1
18 1869
NeoPa
32,556 Recognized Expert Moderator MVP
You have (accidentally) posted this question in the Access Articles section. This is NOT an article.
I'm moving this to the main Access questions forum.

MODERATOR.
Jul 30 '07 #2
NeoPa
32,556 Recognized Expert Moderator MVP
I think you need to reread this to yourself and post it again so that it makes sense. You really can't talk about a whole bunch of items referred to simply by their initials and expect anyone to understand what you mean.
Jul 30 '07 #3
djenkins728
10 New Member
I'm not sure what you are referring to but I only listed the names of the combo boxes which are department, type, boat, and point of contact. And if this is your method of welcoming a Newbie, it's not welcoming.
Jul 31 '07 #4
JKing
1,206 Recognized Expert Top Contributor
Hi, have a look at this tutorial it explains how to link combo boxes / listboxes.

Cascading Combo / List Boxes
Jul 31 '07 #5
djenkins728
10 New Member
The tutorial helped out whole lot and I really appreciate it JKing, but I just have one question. When a name is chosen it brings up all occurences of the department information (ie if John Smith in dept L90 made 13 calls it lists L90 13x). How can I make the dept number only appear once? My code is listed below

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbo_Calledby_AfterUpdate()
  2.     With Me![cbo_deptselect]
  3.         If IsNull(Me!cbo_Calledby) Then
  4.             .RowSource = " "
  5.         Else
  6.             .RowSource = "Select [dept] " & _
  7.                          "From tbl_trial " & _
  8.                          "Where [calledby_id]=" & Me!cbo_Calledby
  9.         End If
  10.         Call .Requery
  11.     End With
  12.  
  13. End Sub
Jul 31 '07 #6
JKing
1,206 Recognized Expert Top Contributor
Hey there, glad you found the tutorial useful. It's always more beneficial to power through something on your own with a little guidance. To get around this you can use the DISTINCT keyword. This should eliminate the duplicates.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbo_Calledby_AfterUpdate()
  2. With Me![cbo_deptselect]
  3. If IsNull(Me!cbo_Calledby) Then
  4. .RowSource = " "
  5. Else
  6. .RowSource = "Select DISTINCT [dept] " & _
  7. "From tbl_trial " & _
  8. "Where [calledby_id]=" & Me!cbo_Calledby
  9. End If
  10. Call .Requery
  11. End With
  12.  
  13. End Sub
  14.  
Give that a go and let me know how it turns out.
Jul 31 '07 #7
djenkins728
10 New Member
JKing you are awesome and again I appreciate your assistance. Now here is my dilemna of where I am stuck- how do I add the other two combo boxes boat and type to the code and have them perform the same and then upon a click oinformation to a form?

Then if a user decides not to start with the cbo_calledby, but instead with cbo_deptselect for instance will the code work in reverse?
Jul 31 '07 #8
JKing
1,206 Recognized Expert Top Contributor
This part I'm not too sure about. If you add code to each afterupdate event of all your combo boxes everytime you move a combo box it will refresh the others and it will just be a big circle. I'm not saying it can't be done in this fashion I just think it would be over complicated and there is probably a better way to handle this.

I can't think of anything great at the moment but maybe one of the other experts will have a good idea.

In the meantime perhaps you could elaborate a little more on the purpose of this form and what exactly it is you're trying to accomplish. The better we know the scenario the easier it is to come up with a solution that fits.
Jul 31 '07 #9
djenkins728
10 New Member
Okay I'll do my best to explain. Based on the selection criteria of the calledby, boat, type, and dept combo boxes, this determines which records from my tbl_maininfo match the criteria. After the user clicks a command button then my form frm_MainInfo opens and displays all data tied to the records.
Jul 31 '07 #10
MMcCarthy
14,534 Recognized Expert Moderator MVP
Okay I'll do my best to explain. Based on the selection criteria of the calledby, boat, type, and dept combo boxes, this determines which records from my tbl_maininfo match the criteria. After the user clicks a command button then my form frm_MainInfo opens and displays all data tied to the records.
The only way I can think to do what you want is to create an option frame of a set of radio buttons to allow the user to first choose which option they wish to start with:
calledby, boat, type, or dept

Now you will need to set up the code to dynamically change the row source of each of the combo boxes depending on that choice. Each of the cascades will have to be coded using CASE statements depending on this choice.

The logic of this is very complicated. Are you sure you want to go down this route? If so, you want to carefully work out the logic of what you are trying to do first.
Jul 31 '07 #11
djenkins728
10 New Member
The only way I can think to do what you want is to create an option frame of a set of radio buttons to allow the user to first choose which option they wish to start with:
calledby, boat, type, or dept

Now you will need to set up the code to dynamically change the row source of each of the combo boxes depending on that choice. Each of the cascades will have to be coded using CASE statements depending on this choice.

The logic of this is very complicated. Are you sure you want to go down this route? If so, you want to carefully work out the logic of what you are trying to do first.
Okay, I will work on that this evening and get back with you on tomorrow. Thanks so much.
Jul 31 '07 #12
NeoPa
32,556 Recognized Expert Moderator MVP
I'm not sure what you are referring to but I only listed the names of the combo boxes which are department, type, boat, and point of contact. And if this is your method of welcoming a Newbie, it's not welcoming.
This is not my "method of welcoming a newbie". It's my job of moderating badly posted questions.
If you are still not sure what I'm referring to try reading your original post again as I suggested. You'll find it makes very little sense (even the sentences aren't properly formed). Obviously POC could mean nothing to anyone but you until your subsequent post clarified that point at least, if not what the question was about.
Jul 31 '07 #13
djenkins728
10 New Member
I've gotten this far with my code, but when I click the submit button it asks for a parameter value instead of opening the frm_maininfofilter. I would rather continue with the If/Then logic instead of using Select/Case since I'm more comfortable with it. Can any one figure out what's wrong with my code?

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_Submit_Click()
  2.    On Error GoTo Err_cmd_Submit_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frm_maininfofilter"
  8.     stLinkCriteria = ""
  9.     If Not IsNull(Me.cbo_deptselect) Then
  10.         stLinkCriteria = "Dept = " & Me.cbo_deptselect                                  
  11.     End If
  12.     If Not IsNull(Me.cbo_Calledby) Then
  13.         If stLinkCriteria = "" Then
  14.             stLinkCriteria = "[Called By] = " & Me.cbo_Calledby
  15.         Else
  16.             stLinkCriteria = stLinkCriteria & " And [Called By] = " & Me.cbo_Calledby
  17.         End If
  18.     End If
  19.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  20.  
  21. Exit_cmd_Submit_Click:
  22.     Exit Sub
  23.  
  24. Err_cmd_Submit_Click:
  25.     MsgBox Err.Description
  26.     Resume Exit_cmd_Submit_Click
  27. End Sub
Aug 1 '07 #14
JKing
1,206 Recognized Expert Top Contributor
What are the data types of the fields Dept and [Called By]? Are they numbers or are they text?
Aug 1 '07 #15
djenkins728
10 New Member
What are the data types of the fields Dept and [Called By]? Are they numbers or are they text?

They are both text fields.
Aug 1 '07 #16
JKing
1,206 Recognized Expert Top Contributor
When using SQL strings with VBA variables of the text type need to be enclosed with single quotes.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_Submit_Click()
  2.    On Error GoTo Err_cmd_Submit_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frm_maininfofilter"
  8.     stLinkCriteria = ""
  9.     If Not IsNull(Me.cbo_deptselect) Then
  10.         stLinkCriteria = "Dept = '" & Me.cbo_deptselect  & "'"                               
  11.     End If
  12.     If Not IsNull(Me.cbo_Calledby) Then
  13.         If stLinkCriteria = "" Then
  14.             stLinkCriteria = "[Called By] = '" & Me.cbo_Calledby & "'"
  15.         Else
  16.             stLinkCriteria = stLinkCriteria & " And [Called By] = '" & Me.cbo_Calledby & "'"
  17.         End If
  18.     End If
  19.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  20.  
  21. Exit_cmd_Submit_Click:
  22.     Exit Sub
  23.  
  24. Err_cmd_Submit_Click:
  25.     MsgBox Err.Description
  26.     Resume Exit_cmd_Submit_Click
  27. End Sub
Give that a go.
Aug 1 '07 #17
djenkins728
10 New Member
When using SQL strings with VBA variables of the text type need to be enclosed with single quotes.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_Submit_Click()
  2.    On Error GoTo Err_cmd_Submit_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frm_maininfofilter"
  8.     stLinkCriteria = ""
  9.     If Not IsNull(Me.cbo_deptselect) Then
  10.         stLinkCriteria = "Dept = '" & Me.cbo_deptselect  & "'"                               
  11.     End If
  12.     If Not IsNull(Me.cbo_Calledby) Then
  13.         If stLinkCriteria = "" Then
  14.             stLinkCriteria = "[Called By] = '" & Me.cbo_Calledby & "'"
  15.         Else
  16.             stLinkCriteria = stLinkCriteria & " And [Called By] = '" & Me.cbo_Calledby & "'"
  17.         End If
  18.     End If
  19.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  20.  
  21. Exit_cmd_Submit_Click:
  22.     Exit Sub
  23.  
  24. Err_cmd_Submit_Click:
  25.     MsgBox Err.Description
  26.     Resume Exit_cmd_Submit_Click
  27. End Sub
Give that a go.

Thanks JKing. I don't receive the parameter value box anymore, but when the form opens it's blank. Within this code where would I add the other two combo boxes, cbo_boat and cbo_type?
Aug 1 '07 #18
djenkins728
10 New Member
I'm still trying to add the two other combo boxes for the selection criteria and then open a form. The other two are cbo_boat and cbo_type. Since cbo_dept updates after the selection of cbo_calledby I added code to attempt to update cbo_boat, but nothing happens. Can someone help?

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbo_Calledby_AfterUpdate()
  2.     With Me![cbo_deptselect]
  3.         If IsNull(Me!cbo_Calledby) Then
  4.             .RowSource = " "
  5.         Else
  6.             .RowSource = "Select DISTINCT [dept] " & _
  7.                          "From tbl_trial " & _
  8.                          "Where [calledby_id]=" & Me!cbo_Calledby
  9.         End If
  10.  
  11.     Call .Requery
  12.     End With
  13.  End Sub
  14. Private Sub cbo_deptselect_AfterUpdate()
  15.    With Me![cbo_boat]
  16.         If IsNull(Me!cbo_deptselect) Then
  17.             .RowSource = " "
  18.         Else
  19.             .RowSource = "Select DISTINCT [boat] " & _
  20.                          "From tbl_trial " & _
  21.                          "Where [calledby_id]= '" & Me!cbo_Calledby & "'"
  22.         End If
  23.     Call .Requery
  24.     End With
  25. End Sub
Aug 1 '07 #19

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

Similar topics

3
4283
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
1
3304
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
0
3491
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the...
0
1577
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
5
3681
by: jjyconsulting | last post by:
Newbie needing some help. I have a tblParticipants. The fields include gender, education_level, income, occupation etc., I'm trying to create a form where a user can run a query from the form and...
4
2349
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
6
3666
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
2898
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a...
2
3258
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
2
2286
by: someshbakliwal | last post by:
Hi, I have created some autopopulating combo boxes on my HTML page (script- Javascript). so these combo boxes are autopopulated with choices made in previous combo boxes. The problem I am facing is...
0
7105
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
6967
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
7132
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,...
0
5439
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,...
0
4564
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
3076
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
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
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 ...
0
266
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...

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.