Option Compare Database Option Explicit Public Declare Sub sapiSleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long) Public Const sgcSuccess = 0 'Return values Public Const sgcFail = -1 'Comments : Mimics the Zap function in dBase 'Parameters: strTable - the table to be cleared 'Sets : 'Returns : success or failure constant 'Created by: Seth D. Galitzer 'Created : 10/29/1998 2:34:26 PM 'Modified : Public Function Zap(strTable As String) As Integer On Error GoTo Err_Zap Const conErrNoTable = 3078 DoCmd.SetWarnings False DoCmd.RunSQL "DELETE * FROM " & strTable & ";" DoCmd.SetWarnings True Zap = sgcSuccess Exit_Zap: Exit Function Err_Zap: Select Case Err Case 0 'insert Errors you wish to ignore here Resume Next Case conErrNoTable MsgBox "The table """ & strTable & """ does not exist in this database.", vbCritical, "Cannot Zap Table" Zap = sgcFail Resume Exit_Zap Case Else 'All other errors will trap Beep MsgBox Err & ": " & Err.Description, vbCritical, "Error in function modGenericFunctions.Zap" Zap = sgcFail Resume Exit_Zap End Select Resume 0 'FOR TROUBLESHOOTING End Function 'Comments : Suggested by Russ Brennan, russ.brennan@nomura.co.uk, 10/28/1998 'Parameters: lngWAIT in MilliSeconds (1000 MilliSeconds per second) 'Created by: Seth D. Galitzer 'Created : 10/28/1998 10:08:14 AM 'Modified : Public Sub Wait(lngWAIT As Long) On Error GoTo Err_Wait Call sapiSleep(lngWAIT) Exit_Wait: Exit Sub Err_Wait: Select Case Err Case 0 'insert Errors you wish to ignore here Resume Next Case Else 'All other errors will trap Beep MsgBox Err.Description, vbCritical, "Error in function modGenericFunctions.Wait" Resume Exit_Wait End Select Resume 0 'FOR TROUBLESHOOTING End Sub 'Comments : Assumes caller wants to know about a form. Taken from Access 97 Developer's Handbook, p. 425. 'Parameters: 'Sets : 'Returns : True if strName is open, False otherwise 'Created by: Litwin, Getz, & Gilbert 'Created : 7/27/1998 9:51:45 AM 'Modified : Function basIsOpen(strName As String, Optional intObjectType As Integer = acForm) On Error GoTo Err_basIsOpen basIsOpen = (SysCmd(acSysCmdGetObjectState, intObjectType, strName) <> 0) Exit_basIsOpen: Exit Function Err_basIsOpen: Select Case Err Case 0 'insert Errors you wish to ignore here Resume Next Case Else 'All other errors will trap Beep MsgBox Err.Description, vbCritical, "Error in function modGenericFunctions.basIsOpen" Resume Exit_basIsOpen End Select Resume 0 'FOR TROUBLESHOOTING End Function 'Comments : Determines if a record is locked in a particular recordset. Inspired by the Access 97 Developer's Handbook. 'Parameters: frm, the form containing the underlying recordset to be examined 'Sets : 'Returns : True or False depending on the current lock state 'Created by: Seth D. Galitzer 'Created : 7/27/1998 2:31:21 PM 'Modified : Function basIsLocked(frm As Form) As Boolean On Error GoTo Err_basIsLocked Const conNoCurrentRecord = 3021 Const conOptimisticLockError = 3186 Const conDataChangedError = 3197 Const conCouldntUpdate = 3218 Const conPessimisticLockError = 3260 Dim rst As Recordset Set rst = frm.RecordsetClone rst.Bookmark = frm.Bookmark rst.Edit rst.Update basIsLocked = False Exit_basIsLocked: Exit Function Err_basIsLocked: Select Case Err Case 0 'insert Errors you wish to ignore here Resume Next Case conNoCurrentRecord basIsLocked = False Resume Exit_basIsLocked Case conPessimisticLockError, conOptimisticLockError, conCouldntUpdate basIsLocked = True Resume Exit_basIsLocked Case conDataChangedError MsgBox Err.Description, vbCritical, "Locking Violated" basIsLocked = False Resume Exit_basIsLocked Case Else 'All other errors will trap Beep MsgBox Err.Description, vbCritical, "Error in function modGenericFunctions.basIsLocked - " & Err.Number basIsLocked = False Resume Exit_basIsLocked End Select Resume 0 'FOR TROUBLESHOOTING End Function 'Comments : Designed to easily convert a null value to a zero-length-string 'Parameters: varData - any data element 'Sets : 'Returns : a zero-length string if the data item is null, or the data item itself 'Created by: Seth D. Galitzer 'Created : 1/5/1999 8:31:15 AM 'Modified : Public Function ToString(varData As Variant) As String On Error GoTo Err_ToString If IsNull(varData) Then ToString = "" Else ToString = varData End If Exit_ToString: Exit Function Err_ToString: Select Case Err Case 0 'insert Errors you wish to ignore here Resume Next Case Else 'All other errors will trap Beep MsgBox Err & ": " & Err.Description, vbCritical, "Error in function modGenericFunctions.ToString" Resume Exit_ToString End Select Resume 0 'FOR TROUBLESHOOTING End Function 'Comments : Called in the OnEnter event of a transparent command button which is the last control ' on a page of a tab control. Moves to the next tab (page) in the tab control or the first ' page if currently on the last page. 'Parameters: tbc - the tab control we want to move in ' intPage (Optional) - the index of the page we are currently on; if not passed in, move to ' the first page 'Sets : 'Created by: Seth D. Galitzer 'Created : To long ago to remember 'Modified : Public Sub basNextPage(tbc As Control, Optional intPage As Integer = -1) On Error GoTo Err_basNextPage Dim pge As Page Dim intPg As Integer If intPage >= 0 Then intPg = intPage + 1 Else intPg = 0 End If Set pge = tbc.Pages(intPg) pge.SetFocus Exit_basNextPage: Exit Sub Err_basNextPage: MsgBox Err.Description, vbCritical, Err.Number Resume Exit_basNextPage End Sub