Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Combobox value does not change

  Asked By: Marjorie    Date: Sep 29    Category: MS Office    Views: 752
  

I have created a combobox that is filled by an ADO recordset, which is based on
the value of another recordset. ie comboboxB items are created based on
selection of comboboxA. This part is currently working fine. However, no matter
which item I select in comboboxB its value remains the same. Can someone help
debug my code as I cant find a solution anywhere.


COMBOBOX is filled using function
--------------------------------------------------------------------------------\
-----
Private Function cboAnalysisLoad(cboDatabase As String)


ConnectDB

Set objSourceRS = New ADODB.Recordset

With objSourceRS
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOptimistic
.ActiveConnection = objConn
End With

gstrSQL = "SELECT Name, Description, Rundate, ID FROM " & cboDatabase &
".dbo.RDM_ANALYSIS RDM_ANALYSIS WHERE EXPOSURETYPE in (8017,8029) ORDER BY Name,
Rundate"

objSourceRS.Open gstrSQL
With cboAnalysis
.Clear
Do While Not objSourceRS.EOF
.AddItem objSourceRS.Fields("Name").Value
.List(0, 1) = objSourceRS.Fields("Description").Value
.List(0, 2) = objSourceRS.Fields("Rundate").Value
.List(0, 3) = objSourceRS.Fields("ID").Value
objSourceRS.MoveNext
Loop

End With


objSourceRS.Close
End Function

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Zane Thompson     Answered On: Sep 29

In case it helps, I call the function  when the userform is initiallised using
the following code.


Private Sub UserForm_Initialize()
With cboDatabase
.AddItem "RMS_RDM_TTY_QUOTES"
.AddItem "RMS_RDM_TREATY"
.Value = "RMS_RDM_TTY_QUOTES"
End With

cboAnalysisLoad (cboDatabase.Value)

End Sub

 
Didn't find what you were looking for? Find more on Combobox value does not change Or get search suggestion and latest updates.




Tagged: