June 27, 2003

Loop Thru and Print Images


1:     Option Compare Database

2: Option Explicit
3:
4: Private Sub Command7_Click()
5: Dim MYIMAGE As String
6: Dim CNN As ADODB.Connection
7: Dim RST As New ADODB.Recordset
8: Dim stDocName As String
9:
10: stDocName = "PrintImagesAuto"
11: DoCmd.SelectObject acForm, stDocName, True
12:
13: 'On Error Resume Next
14: Set CNN = CurrentProject.Connection
15: RST.Open "IMAGES", CNN, adOpenDynamic, adLockOptimistic ', adCmdTableDirect
16: RST.MoveFirst
17:
18: Do Until RST.EOF
19: If RST.EOF Then
20: Exit Sub
21: End If
22:
23: MYIMAGE = RST!Folder
24: Me![Image2].Picture = MYIMAGE
25:
26: 'Print this form
27: DoCmd.PrintOut
28:
29:
30: RST.MoveNext
31: Loop
32:
33: CNN.Close
34: ' RST.Close
35: Set CNN = Nothing
36: Set RST = Nothing
37: DoCmd.SelectObject acForm, stDocName, False
38: End Sub


Posted by sachauncey at June 27, 2003 06:53 PM