Skip to content

Instantly share code, notes, and snippets.

@gsherman
Last active August 16, 2016 22:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gsherman/e5dd6a5223d617a856c604683f942116 to your computer and use it in GitHub Desktop.
Log Notes Form 392 - example of using solutions as canned responses
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Log Notes Form
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Declare Function Utils3_ReplaceString ( OldStr As String, ReplacedStr As String, NewStr As String ) As String
'Hold onto our list of responses
Dim CannedResponsesTextList As List
Dim cannedresponsesTitleList As List
Dim cannedresponsesTitleArray() As String
Dim lastKey As Integer
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Form_Load
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Form_Load()
Me.DoDefault
Dim br As New Bulkretrieve
Dim lor As List
br.SimpleQuery 0, "probdesc"
br.AppendFilter 0, "title", cbLike, "*%"
br.AppendSort 0, "title", cbAscending
br.RetrieveRecords
Set lor = br.getRecordList(0)
Set cannedresponsesTitleList = New List
cannedresponsesTitleList.ItemType = "string"
lor.ExtractList cannedresponsesTitleList, "title"
cobj_lor_solutions.Fill cannedresponsesTitleList
Set CannedResponsesTextList = New List
CannedResponsesTextList.ItemType = "String"
lor.ExtractList CannedResponsesTextList, "description"
ReDim cannedresponsesTitleArray(cannedresponsesTitleList.Count - 1)
ReDim cannedresponsesTitleArray(cannedresponsesTitleList.Count + 1)
Dim i As Integer
cannedresponsesTitleArray(0) = "Select a canned response:"
cannedresponsesTitleArray(1) = ""
For i = 0 To cannedresponsesTitleList.Count - 1
cannedresponsesTitleArray(i + 2) = cannedresponsesTitleList.ItemByIndex(i)
Next i
End Sub
Sub ddl_solutions_click()
Dim newText As String
Me.DoDefault
Dim selectedIndexList As New list
Set selectedIndexList = ddl_solutions.SelectedIndexes
newText = CannedResponsesTextList.ItemByIndex(selectedIndexList.ItemByIndex(0))
Dim extraSpacing As String
If Len(Notes.Text) > 0 Then extraSpacing = ebCrLf
Notes.Text = NOTES.text + extraSpacing + newText
End Sub
Sub NOTES_KeyPress(keyASCII As Integer)
'Debug.Print "Pressed " & keyASCII & " " & Chr$(keyASCII)
If lastKey = 64 And KeyAscii = 64 Then
' 64 is the at sign (@)
Dim result As Integer
result=PopupMenu(cannedresponsesTitleArray)
If result < 2 Then Exit Sub
Dim newText As String
' subtract 2, as the first item is a header, and the second item is blank (which causes an empty line)
newText = CannedResponsesTextList.ItemByIndex(result - 2)
Dim n As string
n = Utils3_ReplaceString ( Notes.Text, "@@", "")
Dim extraSpacing As String
If Len(n) > 0 Then extraSpacing = ebCrLf
Notes.Text = n + extraSpacing + newText
lastKey = 0
Else
lastKey = KeyAscii
End If
Me.DoDefault
End Sub
Sub btn_clear_Click()
Notes.Text = ""
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Message Handler
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Message(ByVal messageNumber As Long, ByVal messageString As String)
Select Case messageNumber
Case cbCloseMessage
Me.Close
Case Else
Me.DoDefault
End Select
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment