473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

link between 2 combo boxes... need help

143 100+
hello everyone..
i have a combobox and in its drop down i have 4 options (company,court,advocate,party).... the address of these options is saving in my database called address.... whenever i select anyone of these option from the dropdown the addresses related to each one of thm has to appear in other combobox automatically and user wil select any of the addresses... i have done the code and its working the problem is showing only the first address of the options and not the rest.. for e.g. if i have 2 address related to company its showing me only the first address.. can anyone help me in this case? thankx in advance
i m putting my code here.


Private Sub cmbadrof_click()
Dim Rs As New ADODB.Recordset
Dim cn As String
Dim address As String
Dim Advocate As String
Dim company As Integer
Dim Court As String
Dim Party As String
Dim adrof As Integer

If cmbadrof.Text = "Advocate" Then
If Rs.State = adStateOpen Then Rs.Close
Rs.Open ("select address from address where adrof = '" & cmbadrof.Text & "'"), Db, adOpenDynamic, adLockOptimistic
cn = Rs.Fields(adrof).Value
Combo1.List(adrof) = cn
'Combo1.Refresh
End If

If cmbadrof.Text = "Company" Then
If Rs.State = adStateOpen Then Rs.Close
Rs.Open ("select address from address where adrof = '" & cmbadrof.Text & "'"), Db, adOpenDynamic, adLockOptimistic
cn = Rs.Fields(adrof).Value
Combo1.List(company) = cn
'Combo1.Refresh
End If

If cmbadrof.Text = "Court" Then
If Rs.State = adStateOpen Then Rs.Close
Rs.Open ("select address from address where adrof = '" & cmbadrof.Text & "'"), Db, adOpenDynamic, adLockOptimistic
cn = Rs.Fields(adrof).Value
Combo1.List(adrof) = cn
'Combo1.Refresh
End If

If cmbadrof.Text = "Party" Then
If Rs.State = adStateOpen Then Rs.Close
Rs.Open ("select address from address where adrof = '" & cmbadrof.Text & "'"), Db, adOpenDynamic, adLockOptimistic
cn = Rs.Fields(adrof).Value
Combo1.List(adrof) = cn
'Combo1.Refresh
End If


End Sub
Jan 29 '09 #1
4 2695
debasisdas
8,127 Expert 4TB
you just need to loop through the recordset.
Jan 29 '09 #2
squrel
143 100+
so i dont knw how to do tht... wld u plz tel me how and wht line i have to add to my code?
thank u
Jan 29 '09 #3
debasisdas
8,127 Expert 4TB
check the if there is any more records in the recordset in a loop. if it is there add too control else exit.

try this
Expand|Select|Wrap|Line Numbers
  1. For i = 1 To RS.RecordCount
  2. Combo1.AddItem RS(0)
  3. RS.MoveNext
  4. Next
  5.  
Jan 29 '09 #4
squrel
143 100+
Thank u very much.... it worked :)
Jan 30 '09 #5

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

Similar topics

1
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...
2
by: CSDunn | last post by:
Hello, In an Access 2000 ADP subform, I have a set of two Radio buttons in a single group that are bound to a field called 'Completed'. The Completed field comes from an SQL Server 2000 table, is...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
3
by: prakashsurya | last post by:
Hi i am having a small problem with combo boxes actually i am preparing a form in which i have to go through the experience in years for that i am using 4 combo boxes. on the first two combo...
4
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
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
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
by: SHAWTY721 | last post by:
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number...
0
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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 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.