• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

Change value in 2nd combo

hi all

i have to 2 combo's in my form both populated from database, but when a particular value is selected from combo1, values in combo2 should change corresponding to the value in combo1...

how do i achieve this...is it possible...??
at the moment its giving me 'Run-time error 3709' - 'Operation is not allowed on an object refrencing a closed or invalid connection'...

tia
MB
0
malharbarai
Asked:
malharbarai
1 Solution
 
DhaestCommented:
private sub combo1_click()
' clearing the second combo
  combo2.clear
' make the sql for retrieving the values from the database
   sql = "select value from table where id = " & combo1.text
' open the recordset
   rs.open connection,sql,adopendynamic,adlockreadonly
' filling the second combo
  while rs.eof = false
     combo2.additem rs.fields(0)
     rs.movenext
  wend
  rs.close
end sub
0
 
sazhagianambiCommented:
Hi,

Normally.

'Run-time error 3709' - 'Operation is not allowed on an object refrencing a closed or invalid connection'...

This Error Occur When You Are Trying To Open a recodset Thru Inavlid Connection object. So Please Check Your Connection Object Status. Most Propably You closed the Connection Object Before Trying to Excute Sql statement. Plz Check it.

Nambi
0
 
CleanupPingCommented:
Hi malharbarai,
This old question (QID 20557021) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
malharbaraiAuthor Commented:
this is what i figured out as the solutions

connString = "select area.serno,area.area,city.serno from area,city where city.city='" & cityVal & "' and area.city_code=city.serno order by area.area"
changeAreaRs.Open connString, ADOConn, adOpenDynamic, adLockReadOnly

While Not changeAreaRs.EOF
    areaCombo.AddItem changeAreaRs("area").Value
    areaCombo.ItemData(areaCombo.NewIndex) = changeAreaRs("area.serno").Value
    changeAreaRs.MoveNext
Wend

changeAreaRs.Close

the solution is much like wat DHAEST suggested, so I would surely like to award him those points

thnx
0
 
DhaestCommented:
Thanks.
I'm glad that the problem is solved now
0
 
malharbaraiAuthor Commented:
Much close to my requirement.

Thnx indeed
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now