Error no 13, type mistmatch

DevAccess

Registered User.
Local time
Yesterday, 19:08
Joined
Jun 27, 2016
Messages
321
Hello

I am assigning an array to word document table cell using vba code.

below is the code
Code:
 Dim getEducation() As String
  p = 0
         
            While Not rsGetEducInfo.EOF
            
            
             p = p + 1
             ReDim Preserve getEducation(p - 1)
               
               getEducation(p - 1) = CStr(rsGetEducInfo.Fields("Education Degree").Value)
              
                rsGetEducInfo.MoveNext
            Wend

''' here is I assign an array to table cell  and here it gives error in below line

wddoc.ActiveWindow.Selection.Tables(1).Cell(3, 2).Range.Text = getEducation()

Please assist waht is wrong here.
 
You cannot set TEXT to an array...
.text= getEducation()

Text must equal string....text="bob"
Set Arrays to arrays,
Ranges to a range.

Besides, arrays are an obsolete method of storage in the object world.
 
You cannot set TEXT to an array...
.text= getEducation()

Text must equal string....text="bob"
Set Arrays to arrays,
Ranges to a range.

Besides, arrays are an obsolete method of storage in the object world.

can you please help me what should be alternative here

like in cell I want to assign

Certi1
certi2
certi3
...

and so on...
 
Can you step back and tell readers in simple English what you are trying to do?
Once we understand WHAT you are trying to accomplish, I'm sure you will get more focused responses as to HOW it might be done in Access.
 
Besides, arrays are an obsolete method of storage in the object world.

I realize this isn't on point, but ever since I "discovered" using Type to make a collection of variables, life has been MUCH simpler.
 
Use the Join() function.

wddoc.ActiveWindow.Selection.Tables(1).Cell(3, 2).Range.Text = Join(getEducation, vbNewLine)

Also, how are arrays obsolete? :confused:
 
I think Ranman256's obsolete means that he doesn't use them.
Like all other constructs, each has its purpose and place. A lot depends on your activity and experience.
There are constructs available that many have not heard of nor used( array, arraylist, dictionary, collection, stack, queue....) That doesn't mean they are obsolete.
 
DevAccess, I attempted to follow your link but it does not work.

I'm going to take a wild leap of faith here for RanMan's comments about arrays. If you can create your own collection, it IS an array (of objects) for which the FOR EACH construct will work, instead of using FOR I=1 TO N. You also can use the .Count property and a few other things to streamline actions.


However, RanMan, NEVER remove any tools from your toolbox. Sometimes an array of scalars is EXACTLY what you need and is the simplest solution. Sometimes you need to take another direction, such as a collection of complex data structures because THAT was the best solution. When you remove too many tools from the toolbox, you run into the case that when all you have left is a hammer, you had better be working with nails.
 

Users who are viewing this thread

Back
Top Bottom