controlling rowsource of a combobox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have three check boxes and one combo box. If I have only 0 or 1 check box
checked I want 'hello', otherwise if I have > 1 checkbox checked I want
'goodbye'. Can anyone help me? where would I put the code, and what would the
code look like? Thank you, Ryan
 
To continue Klatuu Idea
Create a function in the form, something like

Function CheckBox()
intCheckCount = Abs(Nz(Me.Check1, 0) + Nz(Me.Check2, 0) + Nz(Me.Check3, 0))

If intCheckCount = 1 Then
Me.cbo1.RowSource = "Hello"
ElseIf intCheckCount > 1 Then
Me.cbo1.RowSource = "Goodbye"
Else
Me.cbo1.RowSource = ""
End If

End Function
===================
On the after update event of each check box and on the On Current event of
the form run the function in the code section

e.g
Private Sub Check1_AfterUpdate()
CheckBox
End Sub
===================
 
Hello,

This information helped me with my problem, thanks. But, I do have to ask.
My situation is not as complex and I wonder if besides your solution is there
another way to do the following:

I have a combo box which has a QUERY for its rowsource. I would like to
programmatically change the WHERE portion of the query based on a fiscalYear
comboBox control.

Again, using your suggestion for a function worked great, but I just wonder
if I could do all this on one line by replacing the WHERE portion with a
variable?


query
select * from mytable where fiscalYear = ?variable?
 
Hello,

Thanks that is another very good and helpful idea. Still not as streamlined
as I would like, but more than good enough. I can get my work done, so
either of those ideas will work just fine.

Thank you for your super support.
 
Back
Top