Problem with ComboBox Get_Focus()

JezLisle

Registered User.
Local time
Today, 16:06
Joined
Jul 27, 2007
Messages
67
Hi,

This below is my code for the ComboBox_GetFocus() I am having difficulty getting it to associate the intResponseID with anything where am I going wrong?

Private Sub cboResponse_GotFocus()
Dim intResponseID As Integer
intResponseID = Me.Recordset
With Me.cboResponse
.RowSource = _
"SELECT tblCSATResponseType.ResponseItem " & _
"FROM tblCSATResponseType " & _
"WHERE tblCSATResponseType.ResponseID = " & intResponseID
End With
End Sub

The error message I keep getting is Object variable or With block variable not set and am not sure what exactly it means,

Jez.
 
First of all, you can't assign a recordset to an integer datatype. An integer datatype variable handles ONE value at a time. A RECORDSET is just that, a set of records (one or more) and it includes all fields that have been assigned to that recordset. So, depending on what you are trying to accomplish, you may need an array.

But, what exactly, are you trying to achieve. It looks like you are trying to set the rowsource for the combo that you have the code in. Are you trying to do a cascading combo effect?
 
You're referencing a recordset that you haven't declared or opened which is most likely the source of your error message. Are you trying to select the current value then repopulate the combo based on that, as Bob suggests? In which case try
intResponseID = Me.cboResponse
 
Hi, Thanks for the replies.

I am trying to be able to change the values in the ComboBox, but with normal Continous Forms the ComboBox have the same drop downs all the way through. With my form each ComboBox may have a different set of options I want the user to choose, example- some maybe Yes or No and others maybe 0 to 10.

I tried the intResponseID = Me.cboResponse and I still get an error message saying Type Mismatch.

Does what I am trying to do change anything?

Jez
 
If you want to read the data from the combo box in the format yes/no, 0-10, rather than just the number of the selected row, then you need to make the column containing that data the bound column and assign it to a variable of the correct type. Try setting intResponseID to be a variant and then step the code to look at what you're actually reading from the box.
 

Users who are viewing this thread

Back
Top Bottom