How to filter out null elements of an array in MS Access

I'm generating titles out of a few other fields, and want the "right" way to do:

Me.Title.Value = Join(Array([Conference], [Speaker], partstr), " - ")

Except any of [conference], [speaker] or partstr might be null, and I don't want the extra "-"'s. Are there any functions that'll make this job straightforward?


Nope - you'll have to check each one and then cleanup at the end

Dim Temp As String

If Not IsNull([Conference]) Then
  Temp = Temp & [Conference] & " - "
End If

If Not IsNull([Speaker]) Then
  Temp = Temp & [Speaker] & " - "
End If

If Not IsNull(partstr) Then
  Temp = Temp & partstr & " - "
End If

If Temp > "" then
  Me.Title.Value = Left(Temp, Len(Temp) - 3)
  Me.Title.Value = Null
End If

Revised with generic function:

Public Function JoinEx(ByVal pArray As Variant, ByVal pDelimiter As String) As String

  Dim sTemp As String
  Dim iCtr As Integer

  For iCtr = 0 To UBound(pArray)
    If Not IsNull(pArray(iCtr)) Then
      sTemp = sTemp & pArray(iCtr) & pDelimiter
    End If

  If sTemp > "" Then
   JoinEx = Left(sTemp, Len(sTemp) - Len(pDelimiter))
  End If

End Function

Calling Example:

 JoinEx(Array("one","two","three"), " - ")  'Returns "One - Two - Three"
 JoinEx(Array(null,"two","three"), " - ")  'Returns "Two - Three"

Need Your Help

jQuery/Javascript confirm coming up twice

javascript jquery confirm

For some weird reason i'm getting my confirm box coming up twice. here is my code:

TextTrimming not working

c# silverlight xaml windows-phone-7.1.1

I have data binding to a listbox, and texttrimming property set to WordEllipsis, but it doesn't seem to work. The textblocks are showing text as if they do without the texttrimming property set. Th...