add to a dynamic list

L

L Scholes

I have a ComboBox (txtSignature) on a userform that gets it's
information from a dynamic list (DealerName). If I enter a name that is

not in DealerName, I get an error message "Run-time error '381': Could
not get the List property. Invalid property array index." Instead of
this message, I would like to give the user a message allowing three
options:
1) add the new name to the dynamic list and enter the new name onto the

form as if the name were there all along;
2) add as if it were in the list, but don't add it to the list;
3) cancel and do nothing but clear the user form.
Using vbaMsgBoxYesNoCancel, I just don't know how to code it where
above option 1 = yes, 2 = no, 3 = cancel in the MsgBox
Does anybody have the code for this?
Thanks in advance
 
C

Crowbar via OfficeKB.com

Do this to identify the error and then show a NEW userform to add your
desired controls

Above the line that gets the error message put this

On Error Goto ErrorHandler


Somewhere else in the script type

ErrorHandler:
If Err.Number = 381 then
userform.show ' Put you NEW userform name here
exit sub 'Keep this if you want to terminate the userfrom here
end if

With this you will then need to create a NEW userform to accomodate the
controls you require

Let us know how you get on and If you have any trouble you can email me at
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top