excel - check for user input data in dynamically added ComboBoxes -


i using user form display acronyms found in document , definitions of acronyms. because won't know in advance how many there have created of labels, check boxes , comboboxes dynamically using loop below.

i stuck in want allow user able type in combobox new definition example 1 didn't exist in excel database or want use different definition 1 there (i aware bad practice unfortunately people don't stick standard list). works fine set problem want check if user has entered new or not.

so question is, there built in function or variable this? or there simple way it? (i have tried , tested code add string database not issue, checking if wasn't there before without running through entire database scratch again)

    = 1 n          checkboxi = "checkbox" &         labeli = "label" &         comboboxi = "combobox" &          'add checkbox, label , combobox         .multipage1.pages("page1").controls.add "forms.checkbox.1", checkboxi         .multipage1.pages("page1").controls.add "forms.label.1", labeli         .multipage1.pages("page1").controls.add "forms.combobox.1", comboboxi          'position check box         .multipage1.pages("page1").controls(checkboxi).left = leftspacing         .multipage1.pages("page1").controls(checkboxi).top = topspacing + rowheight *          'position labels         .multipage1.pages("page1").controls(labeli).left = leftspacing + 15         .multipage1.pages("page1").controls(labeli).top = topspacing + 2 + rowheight *         .multipage1.pages("page1").controls(labeli).caption = acronyms(i - 1)         .multipage1.pages("page1").controls(labeli).width = 70          'position combobox         .multipage1.pages("page1").controls(comboboxi).left = leftspacing + 100         .multipage1.pages("page1").controls(comboboxi).top = topspacing + rowheight *         .multipage1.pages("page1").controls(comboboxi).width = 300  'find definitions combobox     ' find definition excel document     objwbk.sheets("sheet1")         ' find range of cells data in excel doc         set rngsearch = .range(.range("a1"), .range("a" & .rows.count).end(-4162))          ' search in found range         set rngfound = rngsearch.find(what:=acronyms(i - 1), after:=.range("a1"), lookat:=1)          ' if nothing found count number of acronyms without definitions         if rngfound nothing               ' set cell variable in new table blank             redim targetcellvalue(0) string             targetcellvalue(0) = ""          ' if definition found enter cell variable         else              targetcellvalue(0) = .cells(rngfound.row, 2).value             'msgbox (targetcellvalue(0) & " " & 0)             firstaddress = rngfound.address               until rngfound nothing                 set rngfound = rngsearch.findnext(after:=rngfound)                  if rngfound.address = firstaddress                     exit                 elseif rngfound.address <> firstaddress                     j = j + 1                     redim preserve targetcellvalue(0 j) string                     targetcellvalue(j) = .cells(rngfound.row, 2).value                     'msgbox (targetcellvalue(j) & " " & j)                  end if             loop              end if         end          dim k integer         k = 0 j             .multipage1.pages("page1").controls(comboboxi).additem targetcellvalue(k)         next k         j = 0       next 

i found way it. value typed in user not automatically included in combobox list therefore can check against list see if there before.

code:

for intcomboitem = 0 .multipage1.pages("page1").controls(comboboxi).listcount - 1     if .multipage1.pages("page1").controls(comboboxi).value = .multipage1.pages("page1").controls(comboboxi).list(intcomboitem)       newdef = false       exit    else       newdef = true    end if  next  if newdef    msgbox ("new def: " & .multipage1.pages("page1").controls(comboboxi).value) end if 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -