#1
|
|||
|
|||
User form combo box change from code behind
I have a user form which is launched when the document is opened. A value is chosen from a combobox on the form and some other values are set on textboxes on the form. When the user clicks a command button the value from the combo box is used to find a row on a table in the word document then the index of the selected list item is changed and the user can then click the command button to run the process again.
The problem is that the index is successfully updated and the next value is displayed in the combo box but the value is always empty when read from the code behind. The code that changes the combo boxes item is very simple: Private Sub CommandButton1_Click() On Error GoTo ErrHandle Dim cmbtxt As String cmbtxt = InputForm.Datecmb.SelText Dim idx As Integer idx = InputForm.Datecmb.ListIndex 'Do some work here 'then set the Datecmb list index to the next index InputForm.Datecmb.ListIndex = CInt(idx + 1) ' then exit sub Exit Sub ErrHandle: MsgBox (Err.Description) End If Resume Next End Sub Can anyone sugest what the issue is? |
#2
|
|||
|
|||
Doh!
Figured it out I was looking at the wrong value I was getting the value from the seltext instead of the value changing this has sorted it out!
|
Tags |
combo box, word vba |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Pasting a table with combo boxes to a new document looses the combo box | bobsut@enviro-consult.com | Word | 1 | 01-03-2017 01:29 PM |
How to change font and background colors based on Combo Box selection | KMan3210 | Word VBA | 4 | 12-06-2016 10:11 AM |
Hide a combo box (form control), based on a cell value - Excel 2010 | jaymudda | Excel Programming | 9 | 07-12-2015 10:59 AM |
Outlook form - Combo box for deciding who to send form to | Sambora | Outlook | 0 | 02-09-2014 07:20 AM |
VB Code.. COmbo boxes | DrewB | Word VBA | 4 | 06-10-2009 05:31 AM |