And the IE doesn't allow navigation of the 3 images?
What is code to open images in IE?
And the IE doesn't allow navigation of the 3 images?
What is code to open images in IE?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
In module:
Code:Public Function OpenFirstAttachmentAsTempFile(ByRef rstCurrent As DAO.Recordset, ByVal strFieldName As String) As StringDim rstChild As DAO.Recordset2 Dim fldAttach As DAO.Field2 Dim strFilePath As String Dim strTempDir As String strTempDir = Environ("Temp") ' Get the Temp directory from the environment variable. If Right(strTempDir, 1) <> "\" Then strTempDir = strTempDir & "\" ' Make sure the path always ends with a backslash. Set rstChild = rstCurrent.Fields(strFieldName).Value ' the .Value for a complex field returns the underlying recordset. strFilePath = strTempDir & rstChild.Fields("FileName").Value ' Append the name of the first (and only) attached file to temp dir. If Dir(strFilePath) <> "" Then ' the file already exists--delete it first. VBA.SetAttr strFilePath, vbNormal ' remove any file attributes (e.g. read-only) that would block the kill command. VBA.Kill strFilePath ' delete the file. End If Set fldAttach = rstChild.Fields("FileData") ' The binary data of the file. fldAttach.SaveToFile strFilePath rstChild.Close ' cleanup VBA.Shell "Explorer.exe " & Chr(34) & strFilePath & Chr(34), vbNormalFocus ' Use Windows Explorer to launch the file. End Function 'OpenFirstAttachmentAsTempFileCode:Private Sub lstAtt_DblClick(Cancel As Integer) Dim dbs As DAO.Database Dim rst As DAO.Recordset Const strTable = "tblAttachments" '<- Replace this with your table with attachment Const strField = "Attachments" '<- Replace this with the fieldname of your attachment Set dbs = CurrentDb Set rst = dbs.OpenRecordset("SELECT * FROM tblAttachments WHERE vNumber=" & lblID.Caption) 'rst.MoveNext ' Uncomment this line to go to the 2nd row in the Table. OpenFirstAttachmentAsTempFile rst, strField rst.Close End Sub
No it does not allow to flip through each attachment. I think it's a matter of being stuck on only viewing the first "record".
Code does what it is written to do, open only first attachment. Modify to pass the selected file name to function and run FindFirst on the child recordset.
I modified code to a single procedure.
I find it odd to reference a label control to get parameter.Code:Private Sub lstAtt_DblClick(Cancel As Integer) Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim rstChild As DAO.Recordset2 Dim fldAttach As DAO.Field2 Dim strFilePath As String Dim strTempDir As String Set dbs = CurrentDb Set rst = dbs.OpenRecordset("SELECT * FROM tblAttachments WHERE vNumber=" & Me.lblID.Caption) Set rstChild = rst.Fields("Attachments").Value rstChild.FindFirst "FileName='" & Me.lstAtt & "'" strTempDir = Environ("Temp") ' Get the Temp directory from the environment variable. If Right(strTempDir, 1) <> "\" Then strTempDir = strTempDir & "\" ' Make sure the path always ends with a backslash. strFilePath = strTempDir & rstChild.Fields("FileName").Value ' Append the name of the selected attached file to temp dir. If Dir(strFilePath) <> "" Then ' the file already exists--delete it first. VBA.SetAttr strFilePath, vbNormal ' remove any file attributes (e.g. read-only) that would block the kill command. VBA.Kill strFilePath ' delete the file. End If Set fldAttach = rstChild.Fields("FileData") ' The binary data of the file. fldAttach.SaveToFile strFilePath rstChild.Close ' cleanup rst.Close VBA.Shell "Explorer.exe " & Chr(34) & strFilePath & Chr(34), vbNormalFocus ' Use Windows Explorer to launch the file. End Sub
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.