여러 프로젝트가 있다면 ... 수
조금 더 검색 한 후에 나는 잘 작동하는 Paul Murray's custom database properties을 발견했습니다.
몇 가지 조작으로 일반 속성 추가, 제거 방법을 포함한 모듈을 만들었습니다.
' ---------------------------------
' FUNCTION: AddDbProperty
' Description: add custom properties to a database application
' ---------------------------------
Public Function AddDbProperty(DbProperty As String, _
DbPropertyValue As String, _
Optional DbPropertyType As Long = DB_TEXT, _
Optional DbFilename As String = "Current")
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim prop As Property
If DbFilename = "Current" Then
Set db = DBEngine(0)(0)
Else
Set db = OpenDatabase(DbFilename)
End If
'add the property
Set prop = db.CreateProperty(DbProperty, DbPropertyType, DbPropertyValue)
db.Properties.Append prop
Exit_Handler:
db.Close
Set db = Nothing
Exit Function
Err_Handler:
Select Case Err.Number
Case Else
MsgBox "Error #" & Err.Number & ": " & Err.description, vbCritical, _
"Error encountered (#" & Err.Number & " - AddDbProperty[mod_Dev_Properties])"
End Select
Resume Exit_Handler
End Function
' ---------------------------------
' FUNCTION: RemoveDbProperty
' Description: remove custom properties from a database applciation
' ---------------------------------
Public Function RemoveDbProperty(DbProperty As String, _
Optional DbFilename As String = "Current")
On Error GoTo Err_Handler
Dim db As DAO.Database
If DbFilename = "Current" Then
Set db = DBEngine(0)(0)
Else
Set db = OpenDatabase(DbFilename)
End If
'remove the property
db.Properties.Delete DbProperty
Exit_Handler:
db.Close
Set db = Nothing
Exit Function
Err_Handler:
Select Case Err.Number
Case Else
MsgBox "Error #" & Err.Number & ": " & Err.description, vbCritical, _
"Error encountered (#" & Err.Number & " - RemoveDbProperty[mod_Dev_Properties])"
End Select
Resume Exit_Handler
End Function
' ---------------------------------
' FUNCTION: UpdateDbProperty
' Description: add custom properties to a database application
' ---------------------------------
Public Function UpdateDbProperty(DbProperty As String, _
DbPropertyValue As String, _
Optional DbFilename As String = "Current")
On Error GoTo Err_Handler
Dim db As DAO.Database
If DbFilename = "Current" Then
Set db = DBEngine(0)(0)
Else
Set db = OpenDatabase(DbFilename)
End If
'add the property
db.Properties(DbProperty) = DbPropertyValue
Exit_Handler:
db.Close
Set db = Nothing
Exit Function
Err_Handler:
Select Case Err.Number
Case Else
MsgBox "Error #" & Err.Number & ": " & Err.description, vbCritical, _
"Error encountered (#" & Err.Number & " - UpdateDbProperty[mod_Dev_Properties])"
End Select
Resume Exit_Handler
End Function
IDE 바로 가기 창 속성을 사용하면 추가/업데이트/제거 할 수 있습니다.예를 들어
:
속성을 가져 ?AddDbProperty("My Property Name","My Property value")
은 쉽게도 가능한 입력에 대한 모든 VBA
CurrentDb.Properties("My Property Name")
를 통해
감사를 완료!
'Global' 키워드는 20 년 전에 사용되지 않았습니다. '공중'은 똑같은 일을합니다. 프로젝트 A와 B가 있고 프로젝트 B에서 코드를 사용하려면 프로젝트 A가 필요하다면 프로젝트 A에 프로젝트 B에 * 참조 *가 있어야합니다. 그러나 실제로는 일부 파일에서 구성 설정 읽기/쓰기를 고려하십시오. –
이것이 Access 인 경우, 각 개별 데이터베이스에 ** APP ** 테이블 **라는 APP ** 테이블 ** 정보를 지정하는 것이 더 이치에 맞지 않을까요? – YowE3K
@ YowE3K 어쨌든 나는 항상 Access 태그를 잃어버린다. –