Other Procedures

The SetProperty and GetProperty functions are called from various procedures in the add-in to save values to custom database properties, or retrieve values from them:

Public Sub SetProperty(strName As String, lngType As Long, _

varValue As Variant) 'Called from various procedures

On Error GoTo ErrorHandler

Attempt to set the specified property:

Set dbsCalling = CurrentDb

Set prps = dbsCalling.Properties prps(strName) = varValue

ErrorHandlerExit: Exit Sub

ErrorHandler:

If err.Number = 32 7 0 Then

The property was not found; create it:

Set prp = dbsCalling.CreateProperty(Name:=strName,

Type:=lngType, Value:=varValue) dbsCalling.Properties.Append prp Resume Next Else

& "; Description: " & err.Description Resume ErrorHandlerExit End If

End Sub

Public Function GetProperty(strName As String, strDefault As String) As Variant 'Called from various procedures

On Error GoTo ErrorHandler

Attempt to get the value of the specified property: Set dbsCalling = CurrentDb

GetProperty = dbsCalling.Properties(strName).Value

ErrorHandlerExit: Exit Function

ErrorHandler:

If err.Number = 3270 Then

The property was not found; use default value:

GetProperty = strDefault Resume Next Else

& "; Description: " & err.Description Resume ErrorHandlerExit End If

End Function

The SaveNo and BackEndSaveNo functions create an incremented number for the database (or back-end database) copies:

Public Function SaveNo() As String 'Called from BackupFrontEnd()

On Error GoTo ErrorHandler

Create a unique incrementing save number for today:

intDayNo = Nz(DMax("[SaveNumber]", "zstblBackupInfo", _

"[SaveDate] = Date()")) Debug.Print "Day no. " & intDayNo strNextNo = CStr(intDayNo + 1) Debug.Print "Next No. " & strNextNo SaveNo = strNextNo

ErrorHandlerExit: Exit Function

ErrorHandler:

MsgBox "Error No: " & err.Number & "; Description: " & _

err.Description Resume ErrorHandlerExit

End Function

Public Function BackEndSaveNo() As String 'Called from BackupBackEnd()

On Error GoTo ErrorHandler

Create a unique save number for today:

intDayNo = Nz(DMax("[BackEndSaveNumber]", _ "zstblBackupInfo", _ "[BackEndSaveDate] = Date()")) Debug.Print "Back end Day no. " & intDayNo strNextNo = CStr(intDayNo + 1) Debug.Print "Back end Next No. " & strNextNo BackEndSaveNo = strNextNo

ErrorHandlerExit: Exit Function

ErrorHandler:

MsgBox "Error No: " & err.Number & "; Description: " & _

err.Description Resume ErrorHandlerExit

End Function

0 0

Post a comment