Dear Champika Nirosh
When I try to add a record in a table (' using funtion zAddRec which shown
below'), Say if some other user has locked the table . I have to wait for
some time ,and i want to add the record after he releases the lock
how to proceed with managed exception.
Example :
Private Function zAddRec(sod As tsod) As Boolean
zAddRec = False
On Error GoTo err1
open_table
If Not RsAddNew(mytbl) Then Exit Function
mytbl!Fiscalyear = sod.Fiscalyear
mytbl!CusAcNo = NTrim(sod.CusAcNo)
mytbl!SoNo = NTrim(sod.SoNo)
mytbl!Slno = NTrim(sod.Slno)
If Not RsUpdate(mytbl) Then Exit Function
close_table
zAddRec = True
Exit Function
err1:
gERC = ErrDetails(" B1SOD AddRec")
Select Case gERC
Case gResume: Resume
Case gResumeNext: Resume Next
Case gEnd: End
Case gCxlUpdate: 'IF APPL write code here
Case gUptoU: 'Code here Context sensitive
Case gExit: 'Do nothing (Drops down)
End Select
Exit Function
End Function
****************************************************************************
*****
Public Function ErrDetails%(ByVal Prochead$)
Dim fno%
Dim Ans As Long
'
ErrDetails = gExit
'
If Err.Number > 0 Then
If Err.Number > 3000 And Err.Number < 3999 Then
Select Case Err.Number
Case 3020 'using update without edit/addnew
ErrBox Err.Number & " " & Err.Description
ErrDetails = gEnd
Case 3197
Ans = MsgBox("Data has been changed by another
user,Overwrite changes ?", vbYesNo)
If Ans = vbYes Then
ErrDetails = gResume
Else
ErrDetails = gCxlUpdate
End If
Case Else
ErrBox Err.Number & " : " & Err.Description
ErrDetails = gExit
End Select
Else
ErrBox Err.Number & " : " & Err.Description
ErrDetails = gUptoU
End If
fno = FreeFile
Open oSession.Path & "Err.Txt" For Append As #fno
Print #fno, ERROR DETAILS
Close #fno
End If
End Function
Thanx
Gopal Prabhakaran