-
Notifications
You must be signed in to change notification settings - Fork 3
/
M_omFormFunctions.def
117 lines (107 loc) · 4.19 KB
/
M_omFormFunctions.def
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Option Compare Database
Option Explicit
Public Sub UpdateEnableByTag(Form As Form, tag As String, state As Boolean, Optional delimiter = ",")
Dim ctrl As Control
For Each ctrl In Form.Controls
If omStringFunctions.NotIsNullOrEmpty(ctrl.tag) And (InStr(1, delimiter & ctrl.tag & delimiter, delimiter & tag & delimiter) > 0 Or omStringFunctions.IsNullOrEmpty(tag)) Then
ctrl.Enabled = state
End If
Next
End Sub
Public Sub UpdateVisibleByTag(Form As Form, tag As String, state As Boolean, Optional delimiter = ",")
Dim ctrl As Control
For Each ctrl In Form.Controls
If omStringFunctions.NotIsNullOrEmpty(ctrl.tag) And (InStr(1, delimiter & ctrl.tag & delimiter, delimiter & tag & delimiter) > 0 Or omStringFunctions.IsNullOrEmpty(tag)) Then
ctrl.Visible = state
End If
Next
End Sub
Public Function OpenForm(Name As String, Optional view As AcFormView = AcFormView.acFormDS) As Variant
Name = Replace(Name, "cmd", "")
If InStr(1, Name, "listsearch") <> 0 Then
Name = Replace(Name, "listsearch", "_List_Search")
ElseIf InStr(1, Name, "list") <> 0 Then
Name = Replace(Name, "list", "_List")
view = acNormal
End If
DoCmd.OpenForm Name, view
End Function
Public Sub CloseForms(Optional keepOpen As String = "flow")
Dim frm As Form
For Each frm In Forms
If frm.Name <> keepOpen Then
DoCmd.Close acForm, frm.Name, acSaveNo
End If
Next
End Sub
Public Sub OpenEditScreen(parentForm As Form, FormName As String, Optional keyName As String = "Id", Optional windowMode As AcWindowMode = acDialog, Optional Requery As Boolean = True)
Dim Id As String
If parentForm.CurrentRecord <> -1 Then
If parentForm.Recordset.Fields(keyName).Type = dbGUID Then
Id = StringFromGUID(parentForm.Recordset.Fields(keyName).Value)
Else
Id = parentForm.Recordset.Fields(keyName).Value
End If
DoCmd.OpenForm FormName, datamode:=acFormEdit, windowMode:=windowMode, whereCondition:=keyName & " =" & Id
If Requery Then
parentForm.Requery
End If
End If
End Sub
Public Sub UpdateModifyTracking(frm As Form)
frm.ModifyDate = Now
On Error Resume Next
omUserFunctions.AuthenticateUser
If gUser.LoggedIn Then
frm.ModifyUserName = gUser.Name
frm.ModifyUserId = gUser.Id
Else
frm.ModifyUserName = gUser.Name
frm.ModifyUserId = gUser.Name
End If
End Sub
Public Sub UpdateCreateTracking(frm As Form, Optional UpdateModify = True)
frm.CreateDate = Now
On Error Resume Next
omUserFunctions.AuthenticateUser
If gUser.LoggedIn Then
frm.CreateUserName = gUser.Name
frm.CreateUserId = gUser.Id
Else
frm.CreateUserName = gUser.Name
frm.CreateUserId = gUser.Name
End If
If UpdateModify Then
UpdateModifyTracking frm
End If
End Sub
Public Sub ListFormFields(formName As String)
Dim frm As Form
Dim ctl As Control
Dim intControlOrder As Integer
Dim ts As Scripting.TextStream
Set ts = gFso.CreateTextFile(formName, True)
Set frm = Forms(formName)
For Each ctl In frm.Controls
Debug.Print "Control Name: " & ctl.Name
ts.Write "Control Name|" & ctl.Name & "|"
Debug.Print "Control Type: " & TypeName(ctl)
ts.Write "Control Type|" & TypeName(ctl) & "|"
On Error Resume Next
If Not ctl.Properties("Caption") Is Nothing Then
Debug.Print "Control Caption: " & ctl.Properties("Caption")
ts.Write "Control Caption|" & ctl.Properties("Caption") & "|"
End If
If Not ctl.Properties("LabelName") Is Nothing Then
Debug.Print "Related Label: " & ctl.Properties("LabelName"), frm.Controls(ctl.Properties("LabelName")).Caption
ts.Write "Related Label|" & ctl.Properties("LabelName") & "|"
ts.Write "Related Label Caption|" & frm.Controls(ctl.Properties("LabelName")).Caption & "|"
End If
intControlOrder = ctl.Properties("Order")
Debug.Print "Order: " & intControlOrder
Debug.Print "----------------------"
ts.Write (vbCrLf)
Next ctl
ts.Close
Set ts = Nothing
End Sub