Here is code:
SpeChar(0) = "!"
SpeChar(1) = Chr(34) 'Double Quotation Marks
SpeChar(2) = "#"
SpeChar(3) = "$"
SpeChar(4) = "%"
SpeChar(5) = "&"
SpeChar(6) = Chr(39) 'Single Quotation Mark
SpeChar(7) = "("
SpeChar(8) = ")"
SpeChar(9) = "*"
SpeChar(10) = "+"
SpeChar(11) = ","
SpeChar(12) = "-"
SpeChar(13) = "."
SpeChar(14) = "/"
SpeChar(15) = ":"
SpeChar(16) = ";"
SpeChar(17) = "<"
SpeChar(18) = "="
SpeChar(19) = ">"
SpeChar(20) = "?"
SpeChar(21) = "@"
SpeChar(22) = "["
SpeChar(23) = "\"
SpeChar(24) = "]"
SpeChar(25) = "^"
SpeChar(26) = "_"
SpeChar(27) = "`"
SpeChar(28) = "{"
SpeChar(29) = "|"
SpeChar(30) = "}"
SpeChar(31) = "~"
SpeChar(32) = Chr(13)
SpeChar(33) = Chr(10)
SpeChar(34) = " "
EscChar(0) = "%21" 'Exclamation Point
EscChar(1) = "%22" 'Double Quotation Marks
EscChar(2) = "%23" 'Hash Mark/Number Sign
EscChar(3) = "%24" 'Dollar Sign
EscChar(4) = "%25" 'Percent Sign
EscChar(5) = "%26" 'Ampersand
EscChar(6) = "%27" 'Apostrophe Single Quotation Mark
EscChar(7) = "%28" 'Left Parenthesis
EscChar(8) = "%29" 'Right Parenthesis
EscChar(9) = "%2A" 'Asterisk
EscChar(10) = "%2B" 'Plus Sign
EscChar(11) = "%2C" 'Comma
EscChar(12) = "%2D" 'Dash or Minus Sign
EscChar(13) = "%2E" 'Period
EscChar(14) = "%2F" 'Forward Slash
EscChar(15) = "%3A" 'Colon
EscChar(16) = "%3B" 'Semicolon
EscChar(17) = "%3C" 'Left Arrow
EscChar(18) = "%3D" 'Equal Sign
EscChar(19) = "%3E" 'Right Arrow
EscChar(20) = "%3F" 'Question Mark
EscChar(21) = "%40" 'At Sign
EscChar(22) = "%5B" 'Left Bracket
EscChar(23) = "%5C" 'Backward Slash
EscChar(24) = "%5D" 'Right Bracket
EscChar(25) = "%5E" 'Up Arrow
EscChar(26) = "%5F" 'Underscore
EscChar(27) = "%60" 'Acute, Back quote, grave, grave accent, left quote, open quote, or a push
EscChar(28) = "%7B" 'Left Curly Bracket
EscChar(29) = "%7C" 'Vertical Line
EscChar(30) = "%7D" 'Right Curly Bracket
EscChar(31) = "%7E" 'Tilde
EscChar(32) = "%0A" 'Line Feed
EscChar(33) = "%0D" 'Carriage Return
EscChar(34) = "%20" 'Blank space
Dim db As Database
Dim rs As Recordset
Dim Message As String 'This will hold the Message under the Specific Details label on the ORDERS form.
Dim newMessage As String 'This will hold a processed version of the Message text.
Dim newMessage2 As String
Dim OrderID As Long 'This will hold the order ID, a number distinct from the sales order number.
Dim ProductID As String 'This will hold the product ID.
Dim newTextChar As String
Dim charCount As Long
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT ORDERS.OrderNumber, ORDERS.OrderID, ORDERS.Message, " & _
"Trim(ORDERS.ProductID & ' ' & ORDERS.OptionConfig) AS ProductID FROM ORDERS " & _
"INNER JOIN Proofs ON ORDERS.OrderID = Proofs.OrderID " & _
"WHERE Proofs.proofReq = True AND ORDERS.OrderDate>=#1/1/2013# " & _
"AND ORDERS.OrderNumber = " & SONumber, dbReadOnly)
Message = ""
newMessage = ""
If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
If Len(rs!Message) > 0 Then
Message = rs!Message 'Gets the Message.
charCount = Len(rs!Message)
For i = 1 To charCount
newTextChar = Mid(rs!Message, i, 1)
If (Asc(Mid(rs!Message, i, 1)) > 57 And Asc(Mid(rs!Message, i, 1))) < 65 _
Or (Asc(Mid(rs!Message, i, 1)) > 90 And Asc(Mid(rs!Message, i, 1))) < 97 _
Or Asc(Mid(rs!Message, i, 1)) < 32 _
Or Asc(Mid(rs!Message, i, 1)) > 122 Then
For j = 0 To 34
If SpeChar(j) = newTextChar Then
charFound = True
newMessage = newMessage & EscChar(j)
Exit For
Else
charFound = False
End If
Next
End If
If charFound = False Then
newMessage = newMessage & newTextChar
End If
newTextChar = ""
Next
OrderID = rs!OrderID
ProductID = rs!ProductID
Call UpdateActivity(SONumber, OrderID, ProductID, newMessage) 'Shows the message as a comment under Activity.
End If
rs.MoveNext
Loop
End If
Public Function UpdateActivity(SONumber, OrderID, ProductID As String, Message As String)
Dim db As Database
Dim rs As Recordset
Dim cardID As String
Call SetGlobalValues
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT cardID FROM TR_CARDS WHERE OrderNumber = " & _
SONumber, dbReadOnly)
If rs.RecordCount = 1 Then
cardID = rs!cardID
Call AddTrelloActivity(cardID, "The details for the " & ProductID & " on order %23" & _
SONumber & " now read: " & Message & ". " & _
"The order ID code for this line item is " & OrderID & ".")
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Function
Public Function AddActivity(cardID, textVal)
Dim objSvrHTTP As MSXML2.ServerXMLHTTP60 'Declares an variable for use in establishing HTTP connections.
Set objSvrHTTP = New MSXML2.ServerXMLHTTP60 'Creates an instance of an object for establishing HTTP connections.
Dim trURL As String 'This will hold a URL with information needed to perform a task on Trello.
'This initializes trURL with information needed to add comments to a Trello card.
trURL = "
& _
"cards/" & cardID & "/actions/comments/?text=" & textVal & _
"&key=" & keyVal & "&token=" & tokenVal
objSvrHTTP.Open "POST", trURL 'Initializes a request and specifies the method, URL, and needed authentication information, if any.
objSvrHTTP.SetRequestHeader "Content-Type", "application/json" 'Specifies the name of an HTTP header.
objSvrHTTP.Send ("") 'Sends an HTTP request to the server and receives a response.
Set objSvrHTTP = Nothing
End Function