[COLOR="Navy"]Sub[/COLOR] Err_Test()
[COLOR="navy"]On Error GoTo[/COLOR] Err_Handler
[COLOR="navy"]Dim[/COLOR] X [COLOR="navy"]As Long
For[/COLOR] X = 1 [COLOR="navy"]To[/COLOR] 10
[COLOR="DarkGreen"]' Insert your loop code here[/COLOR]
Skip:
[COLOR="navy"]Next[/COLOR] X
[COLOR="navy"]Exit Sub[/COLOR]
Err_Handler:
[COLOR="darkgreen"]' Insert your Error Handling Code here[/COLOR]
[COLOR="navy"]Resume[/COLOR] Skip
[COLOR="navy"]End Sub[/COLOR]
[COLOR="Navy"]Dim[/COLOR] rs [COLOR="navy"]As[/COLOR] DAO.Recordset
[COLOR="navy"]Dim[/COLOR] X [COLOR="navy"]As Long
Set[/COLOR] rs = DBEngine(0)(0).OpenRecordset("SELECT ...")
[COLOR="navy"]On Error GoTo[/COLOR] Err_RS_Skip
[COLOR="navy"]Do While Not[/COLOR] rs.EOF
[COLOR="darkgreen"]' Insert recordset code here[/COLOR]
Err_RS_Skip:
[COLOR="navy"]If Not[/COLOR] rs.EOF [COLOR="navy"]Then[/COLOR] rs.MoveNext
[COLOR="navy"]Loop[/COLOR]
rs.Close
[COLOR="navy"]Set[/COLOR] rs = [COLOR="navy"]Nothing
On Error GoTo[/COLOR] Err_For_Next_Skip
[COLOR="navy"]For[/COLOR] X = 1 [COLOR="navy"]To[/COLOR] 100
[COLOR="DarkGreen"]' Insert For-Next code here[/COLOR]
Err_For_Next_Skip:
[COLOR="navy"]Next[/COLOR] X
Sub ContainerPropertyX()
[COLOR=green]'Code written by wazz 2008-06-29 18:28[/COLOR]
[COLOR=green]'Last modified by wazz[/COLOR]
[COLOR=green]'2008-06-29: - needs work. getting error 3265 on:[/COLOR]
[COLOR=green]' Debug.Print "Document: " & contLoop.Documents(0).Name[/COLOR]
[COLOR=green]' "item not found in this collection."[/COLOR]
[COLOR=green]'2009-04-11: - added label.[/COLOR]
On Error GoTo ErrorHandler
Dim db As Database
Dim contLoop As Container
Set db = CurrentDb
[COLOR=green] ' Display the container name for the first Document[/COLOR]
[COLOR=green] ' object in each Container object's Documents collection.[/COLOR]
For Each contLoop In db.Containers
[COLOR=green]'Debug.Print db.Containers(0).Name[/COLOR]
Debug.Print "Container: " & contLoop.Documents(0).Container
Debug.Print " Document(0): " & contLoop.Documents(0).Name
ResumeNext:
Next contLoop
db.Close
Set db = Nothing
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err.Number = 3265 Then
Debug.Print "doc(0) not found in this collection "
GoTo ResumeNext
End If
MsgBox "Error Number: " & Err.Number & vbCrLf & _
"Error Description: " & Err.Description & vbCrLf & _
"Procedure: ContainerPropertyX"
Resume ErrorHandlerExit
Resume
End Sub
Dim db As DAO.Database
Dim iCtrLoop As Integer
Set db = CurrentDb
[COLOR=green]'Loop all containers.[/COLOR]
For iCtrLoop = 0 To db.Containers.Count - 1
With db.Containers(iCtrLoop)
[COLOR=green]'Display the container name.[/COLOR]
Debug.Print "Container: " & .Name
[COLOR=green]'If count value is zero, there are no objects in the collection.[/COLOR]
If .Documents.Count > 0 Then
Debug.Print " Document(0): " & .Documents(0).Name
Else
Debug.Print " Container """ & .Name & """ contains no docs. "
End If
End With
Next iCtrLoop
Set db = Nothing
ErrorHandler:
If Err.Number = 3265 Then
Debug.Print "doc(0) not found in this collection "
GoTo ResumeNext
End If
MsgBox "Error Number: " & Err.Number & vbCrLf & _
"Error Description: " & Err.Description & vbCrLf & _
"Procedure: ContainerPropertyX"
Resume ErrorHandlerExit
Resume
End Sub
On Error GoTo ErrorHandler 'see below
Dim db As Database
Dim contLoop As Container
Set db = CurrentDb
' Display the container name for the first Document
' object in each Container object's Documents collection.
For Each contLoop In db.Containers
On Error GoTo ErrorHandler 'my addition