前面提及到如何上传和显示图片。都是一条记录对应一张图片的。那么如何显示多张图片呢?
下面的示例不仅可以显示多张图片,还可以通过双击另图片变大。点击ReviviF,即可是图片还原。
详细源码:
Option Compare Database
Dim ImageWidth, ImageHeight, ImageWidth1, ImageHeight1, ImageWidth2, ImageHeight2 As Long
Private Sub Label12_Click()
DoCmd.GoToRecord , , acNext
End Sub
Private Sub Label13_Click()
DoCmd.GoToRecord , , acPrevious
End Sub
Private Sub Label17_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label17.ForeColor = X * Y
End Sub
Private Sub Label18_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label18.ForeColor = X * Y
End Sub
Private Sub Label4_Click()
DoCmd.Quit
End Sub
Private Sub BookImage_DblClick(Cancel As Integer)
Me.BookImage.Height = Me.BookImage.Height * 1.1
Me.BookImage.Width = Me.BookImage.Width * 1.1
End Sub
Private Sub BookImage1_DblClick(Cancel As Integer)
Me.BookImage1.Height = Me.BookImage1.Height * 1.1
Me.BookImage1.Width = Me.BookImage1.Width * 1.1
End Sub
Private Sub BookImage2_DblClick(Cancel As Integer)
Me.BookImage2.Height = Me.BookImage2.Height * 1.1
Me.BookImage2.Width = Me.BookImage2.Width * 1.1
End Sub
Private Sub Form_Load()
DoCmd.RunCommand acCmdAppMinimize
ImageWidth = Me.BookImage.Width
ImageHeight = Me.BookImage.Height
ImageWidth1 = Me.BookImage1.Width
ImageHeight1 = Me.BookImage1.Height
ImageWidth2 = Me.BookImage2.Width
ImageHeight2 = Me.BookImage2.Height
End Sub
Private Sub Label14_Click()
Me.BookImage.Height = ImageHeight
Me.BookImage.Width = ImageWidth
Me.BookImage1.Height = ImageHeight1
Me.BookImage1.Width = ImageWidth1
Me.BookImage2.Height = ImageHeight2
Me.BookImage2.Width = ImageWidth2
End Sub
Private Sub Form_Current()
If Dir(CurrentProject.Path & "\productphoto\" & Me.ProductCode & "a.jpg") = "" Then
BookImage.Picture = ""
BookImage1.Picture = ""
BookImage2.Picture = ""
Else
BookImage.Picture = CurrentProject.Path & "\productphoto\" & Me.ProductCode & "a.jpg"
BookImage1.Picture = CurrentProject.Path & "\productphoto\" & Me.ProductCode & "b.jpg"
BookImage2.Picture = CurrentProject.Path & "\productphoto\" & Me.ProductCode & "c.jpg"
End If
End Sub
Private Sub Label7_Click()
Me.BookImage.Height = ImageHeight
Me.BookImage.Width = ImageWidth
Me.BookImage.Height = ImageHeight
Me.BookImage1.Width = ImageWidth
Me.BookImage1.Height = ImageHeight
Me.BookImage2.Width = ImageWidth
Me.BookImage2.Height = ImageHeight
End Sub