Hi,
I want to be able to show a popup message once every 14 days. How do Icode
this in VB. Thanks in advance.
PR
create a custom property of type Date.
then use these routines to Get and Set the date...
If you create a popup form to handle this, you could set the value in
the Close event of the form.
Option Explicit
'-----------Start Code Block-----------
Function SetCustomProperty(strPropName As String, intPropType _
As Integer, strPropValue As String) As Integer
Dim dbs As Database, cnt As Container
Dim Doc As Document, prp As Property
Const conPropertyNotFound = 3270 ' Property not found error.
Set dbs = CurrentDb ' Define Database object.
Set cnt = dbs.Containers!Databases ' Define Container object.
Set Doc = cnt.Documents!UserDefined ' Define Document object.
On Error GoTo SetCustom_Err
Doc.Properties.Refresh
' Set custom property name. If error occurs here it means
' property doesn't exist and needs to be created and appended
' to Properties collection of Document object.
If strPropName = "" Then GoTo SetCustom_Bye Else
Set prp = Doc.Properties(strPropName)
prp = strPropValue ' Set custom property value.
SetCustomProperty = True
SetCustom_Bye:
Exit Function
SetCustom_Err:
If Err = conPropertyNotFound Then
Set prp = Doc.CreateProperty(strPropName, intPropType,
strPropValue)
Doc.Properties.Append prp ' Append to collection.
Resume Next
Else ' Unknown error.
SetCustomProperty = False
Resume SetCustom_Bye
End If
End Function
Function GetCustomProperty(strPropName As String) As String
Dim dbs As Database, cnt As Container
Dim Doc As Document, prp As Property
' Property not found error.
Const conPropertyNotFound = 3270
On Error GoTo GetCustomProperty_Err
Set dbs = CurrentDb
Set cnt = dbs.Containers!Databases
Set Doc = cnt.Documents!UserDefined
Doc.Properties.Refresh
GetCustomProperty = Doc.Properties(strPropName)
GetCustomProperty_Bye:
Exit Function
GetCustomProperty_Err:
If Err = conPropertyNotFound Then
Set prp = Doc.CreateProperty(strPropName, dbText, "None")
' Append to collection.
Doc.Properties.Append prp
Resume
Else
' Unknown error.
GetCustomProperty = ""
Resume GetCustomProperty_Bye
End If
End Function
'-----------End Code Block-----------