Rowsource of combo box won't update from VBA

mkelly2384
mkelly2384 used Ask the Experts™
on
I have a combo box called cboAction, and I want to edit the list values within it based on different selections made by the user.  This is the code that I have.  It doesn't produce any errors, but it also doesn't change the dropdown values in the combo box.  Can someone help?
Function ActionListChange()
   'If this is a task being assigned (and is not an incoming communication) then change the
   'values of the Action Type to more appropriate selections.
   Dim strRowSource1 As String
   Dim strRowSource2 As String
   Dim strRowSource3 As String
   
   strRowSource1 = """Email or Call"";""Email"";""Call"";""Mail"";""Other"""
   strRowSource2 = """Emailed"";""Called"";""Mailed"";""Other"""
   strRowSource3 = """Contact"";""Email"";""Call"";""Mail"";""Other"""
   
      If Me.cboCreator <> Me.cboStaff Then
         If Not IsNull(Me.cboStaff) Then
            Me.cboAction.RowSource = strRowSource1
         Else
            Me.cboAction.RowSource = strRowSource3
         End If
      End If
            
      If Me.optIncoming Then
         Me.cboAction.RowSource = strRowSource2
      Else
         Me.cboAction.RowSource = strRowSource3
      End If
      
      Me.cboAction.Requery

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Commented:
Without a sample, that's hard!
Put a breakpoint on each Me.cboAction.RowSource = line and on Me.cboAction.Requery
Get your code to run.
See if it is even selecting an option, first.

Next, your strings just need to be:
"Email or Call;Email;Call;Mail;Other"

All those extra quotes may be confusing things.
Why do you have so many quotes anyway?

Author

Commented:
When you're putting quote inside of quotes you use double quotes, but maybe that isn't necessary in this case.

I did use breakpoints, and when I scrolled over "me.cboAction.RowSource" it showed that it HAD changed the RowSource values.  But when I click on the combo box, the values weren't changed.
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012
Commented:
What you are loading there requires the "RowSourceType" property to be set to "Value list".

If this property of the combobox is/was originally set for something else, then you would have to first change the "RowSourceType" property in the code to "Value list"

Finally, you are not stating when you are running this (on what event(s)), so it  is hard to determine if that event is optimal.

Author

Commented:
I went ahead and scrapped this plan and am not going to change the row source at all, as it wasn't owrth anymore time.  Thanks for the input anyway, gentlemen!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial