-
Notifications
You must be signed in to change notification settings - Fork 3
/
M_omSourceObject.def
40 lines (35 loc) · 1.03 KB
/
M_omSourceObject.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
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database
Option Explicit
Dim rs As New ADODB.Recordset
Public Id As Long
Public Name As String
Public ObjectTypeId As AcObjectType
Public Sub Load(obj As Object, Optional objType As AcObjectType = 0)
Me.Name = obj.Name
If objType = 0 Then
objType = IIf(Left(TypeName(obj), 5) = "Form_", AcObjectType.acForm, AcObjectType.acReport)
End If
Me.ObjectTypeId = objType
rs.Filter = "ObjectTypeId=" & objType & " AND Name='" & obj.Name & "'"
If rs.EOF Then
rs.AddNew
rs("ObjectTypeId") = objType
rs("Name") = obj.Name
rs("CreateDate") = Now
rs.Update
End If
rs("LastUsedDate") = Now
rs.Update
Id = rs("Id")
End Sub
Private Sub Class_Initialize()
rs.Open "omSourceObjects", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
End Sub
Private Sub Class_Terminate()
rs.Close
Set rs = Nothing
End Sub