Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / January 2005

Tip: Looking for answers? Try searching our database.

Text box to show the results of a combo box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lucian Sitwell - 16 Jan 2005 18:30 GMT
I have made a user defined vba form in word to add the non-mailing addresses
from Outlook (if needed to the document) (since the address book dialog will
only let me paste in the mailing address in Word 2003).

I am able to load the data into an array, which displays properly in the
combo box.  However, I can't get the  full data from record in the combo box
to display in the text box.

   Dim MyArray
   Dim intIndex As Integer
   intIndex = cboContact.ListIndex
   txtContactAddress.Text = MyArray(intIndex)-------------this line gives
me a type mismatch.

Also, although the array is declared in the initialization of the form, I
get an error, if I don't declare it separately in the subroutine for the
text box.  Is this supposed to happen? Why?

Any help would be appreciated.

Thanks

Lucian Sitwell
Michael Bauer - 16 Jan 2005 19:25 GMT
Hi Lucian,

> Also, although the array is declared in the initialization of the form, I
> get an error, if I don't declare it separately in the subroutine for the
> text box.

maybe that´s the problem. If I understand you correctly, then you
declare MyArray in "the initialization of the form", this array contains
the data as expected, then you need the array in another subroutine, and
declare it again: So this array is new and empty.

There are two ways: You can

a) declare the array in the modul head, then it is in the scope of each
modul method,

b) spend your subroutine signature an argument. This way I would prefer.

Example:

Sub Init()
 Dim MyArray() As Variant
 ...
 ' call the subroutine and pass the variable
 YourSubRoutine MyArray
 ...
End Sub

Sub YourSubRoutine(MyArray As Variant)
 ...
End Sub

In addition:

>     Dim MyArray
This declares just a variant type variable not an array...

>     ... MyArray(intIndex)...
... so this must lead into an exception.

Signature

Viele Grüße
Michael Bauer

> I have made a user defined vba form in word to add the non-mailing addresses
> from Outlook (if needed to the document) (since the address book dialog will
[quoted text clipped - 19 lines]
>
> Lucian Sitwell
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.