-
Notifications
You must be signed in to change notification settings - Fork 3
/
AutoCorrect
60 lines (40 loc) · 1.75 KB
/
AutoCorrect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Function pfAutoCorrect()
'============================================================================
' Name : pfAutoCorrect
' Author : Erica L Ingram
' Copyright : 2019, A Quo Co.
' Call command: Call pfAutoCorrect
' Description : adds entries as listed on form (from matching table row) to rough draft autocorrect in Word
'============================================================================
Dim db As Database
Dim flCurrentField As DAO.Field
Dim sFieldName As String, sACShortcutsSQL As String, sFieldValue As String
Dim rstAGShortcuts As DAO.Recordset
sCourtDatesID = Forms![NewMainMenu]![ProcessJobSubformNMM].Form![JobNumberField]
sACShortcutsSQL = "SELECT * FROM AGShortcuts WHERE [CourtDatesID] = " & sCourtDatesID & ";"
Set db = CurrentDb()
Set rstAGShortcuts = db.OpenRecordset(sACShortcutsSQL)
With ActiveDocument
For Each flCurrentField In rstAGShortcuts.Fields
sFieldName = LCase(flCurrentField.Name)
If sFieldName = "CourtDatesID" Then
GoTo NextAGShortcut
ElseIf sFieldName = "CasesID" Then
GoTo NextAGShortcut
ElseIf sFieldName = "ID" Then
GoTo NextAGShortcut
Else
End If
If IsNull(rstAGShortcuts.Fields(sFieldName).Value) Or rstAGShortcuts.Fields(sFieldName).Value = "" Or rstAGShortcuts.Fields(sFieldName).Value = " " Then
GoTo NextAGShortcut
Else
sFieldValue = rstAGShortcuts.Fields(sFieldName).Value
.Application.AutoCorrect.Entries.Add sFieldName, sFieldValue
End If
NextAGShortcut:
Next
End With
rstAGShortcuts.Close
Set flCurrentField = Nothing
Set rstAGShortcuts = Nothing
End Function