Thread: JOIN an array
View Single Post
  #1 (permalink)  
Old November 8th, 2004, 02:40 PM
Jen Jen is offline
Registered User
 
Join Date: Nov 2004
Location: London, Ontario, Canada.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default JOIN an array

Hi all

I need to take all instances of sub-item descriptions and pop them into another textbox as a concatenated string - so basically I am trying to define the sub-item descriptions as an array and then JOIN and TRIM them so that I end up with a string made up of all of these descriptions. I get a type mismatch error at the moment when I try to define Descrip as an array equal to the description field and when I take that line out (see below), I get a null string because it isn't pulling from anything. So basically my questions is: what am I doing wrong? And how do I join an array of strings into one result string?

This is my code:

Dim CountSub As Long
CountSub = Forms!frmPricingSheet!frmPricingsubform![SubItemCount]
Dim Descrip() As String
Descrip = Forms!frmPricingSheet!frmPricingsubform![Description] (Error here)

Dim CompDesc As String
ReDim Preserve Descrip(1 To CountSub) As String

CompDesc = ""
    For CountSub = 1 To UBound(Descrip)
        If Descrip(CountSub) <> "" Then
        If CompDesc = "" Then CompDesc = CompDesc & " "
        CompDesc = CompDesc & Trim(Descrip(CountSub))
    End If
Next

Forms!frmPricingSheet![Description].Value = CompDesc

Thanks!

Jen
Reply With Quote