Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

A big shout out to Crystal Long (strive4peace) for this Access Add-In.

So, I have simply been using a plugin on my WordPress site that I post the daily article to which in turn is picked up by my Kit account RSS feed reader and auto-emailed to everyone.

I’ve always wanted to have the syntax highlighting from the Prismatic plugin I was using to show up in the email that gets sent, but the email would always just show the code in plain text. So I had already researched different plugins and embedding CSS into the RSS feed which did not seem simple or straightforward, at least for the time I wanted to spend on it, but then I found this ColorCode add in for Access:

https://www.msaccessgurus.com/tool/Addin_ColorCode.htm

This add-in allows me to pull up a form which will translate my code into HTML using color embedded into the HTML. This should allow me to embed the color coded snippet in WordPress and I **think** it will then simply be passed along as HTML in the email that gets sent. So here is my test. It is a function I wrote to see if an array had anything allocated to it yet.

Public Function IsArrayAllocated(Arr As Variant) As Boolean 
   ''''''''''''''''''''''''''''''''''''''''''''''''''''''''
   ' Procedure Name: IsArrayAllocated
   ' Purpose:
   ' Returns TRUE if the array is allocated (either a static array or a dynamic array
   ' that has been sized with Redim) or FALSE if the array is not allocated (a dynamic
   ' that has not yet been sized with Redim, or a dynamic array that has been Erased).
   ' Static arrays are always allocated.
   '
   ' The VBA IsArray function indicates whether a variable is an array, but it does not
   ' distinguish between allocated and unallocated arrays. It will return TRUE for both
   ' allocated and unallocated arrays. This function tests whether the array has actually
   ' been allocated.
   '
   ' Procedure Kind: Function
   ' Procedure Access: Public
   ' Parameter Arr (Variant): A variable to be tested
   ' Return Type: Boolean, true if the parameter is an array with at least one element,
   '              false otherwise
   ' Author: Jon
   ' Date: 8/17/2020
   ''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   Dim N As Long 
   On Error Resume Next 

   ' if Arr is not an array, return FALSE and get out.
   If IsArray(Arr) = False Then 
      IsArrayAllocated = False 
      Exit Function 
   End If 

   ' Attempt to get the UBound of the array. If the array has not been allocated,
   ' an error will occur. Test Err.Number to see if an error occurred.
   N = UBound(Arr,1) 
   If (Err.Number = 0) Then 
      ''''''''''''''''''''''''''''''''''''''
      ' Under some circumstances, if an array
      ' is not allocated, Err.Number will be
      ' 0. To acccomodate this case, we test
      ' whether LBound <= Ubound. If this
      ' is True, the array is allocated. Otherwise,
      ' the array is not allocated.
      '''''''''''''''''''''''''''''''''''''''
      If LBound(Arr) <= UBound(Arr) Then 
         ' no error. array has been allocated.
         IsArrayAllocated = True 
      Else 
         IsArrayAllocated = False 
      End If 
   Else 
      ' error. unallocated array
      IsArrayAllocated = False 
   End If 

End Function 

So, there it is in all it’s glory. I see in my WordPress preview that it is colored and fully expect it to be when sent to you. Please let me know if you don’t see the above code with syntax highlighting.

Sign up For a Daily Email Adventure in Microsoft Access

Every business day (typically M-F), I'll send you an email with information about my ongoing journey as an advanced Access application developer. It will be loaded with my tips and musings.

    We won't send you spam. Unsubscribe at any time.