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?

Answers


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)
Else
  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
  Next

  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

Eclipse Kepler 4.3 - Error while installing software JBoss Tools

java eclipse maven jboss

In Eclipse Kepler 4.3 I am trying to install JBoss Tools for Kepler 4.3 from site. I am using JBoss Tools 4.1.2 Final. I am getting below multiple errors. Find error details below:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.