问题描述
我真的很挣扎,想知道是否有人可以帮忙?我正在尝试使用已完成的图像并使用图片的文件路径来建立数据库。它运作良好并且很好,但是下一步是要有一个表单,该表单仅显示每个记录中的图片以用作目录,然后单击该表单中的特定图片时,它将打开另一个包含所有内容的表单记录并直接转到该指定记录。我们已经设法使其适用于第一张图像并进行记录,但无法解决如何使其转到下一记录的下一幅图像。我正在尝试为此使用多行形式,并且只显示图片。我只是使用基本代码,因为我只是从VBA开始的,但我相信这可能行不通。有人可以帮助我吗?
我使用了以下在线建议的代码来处理图片,然后在其中添加了一些其他的vba代码。我需要创建一个目录库存,但我们想单击库存项目的图片,然后打开一个包含所有详细信息的表单。我发现使用连续表单和透明按钮可以使您转到特定记录,但是您似乎无法更改布局。理想情况下,我正在寻找一种表单,其中的网格样式图像仅遍及页面,而不仅仅是列表位于页面下方...如果这样有意义?
Option Compare Database
Option Explicit
Public Function DisplayImage(ctlImageControl As Control,strImagePath As Variant) As String
On Error GoTo Err_DisplayImage
Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer
With ctlImageControl
If IsNull(strImagePath) Then
.Visible = False
strResult = "No image name specified."
Else
If InStr(1,strImagePath,"\") = 0 Then
' Path is relative
strDatabasePath = CurrentProject.FullName
intSlashLocation = InStrRev(strDatabasePath,"\",Len(strDatabasePath))
strDatabasePath = Left(strDatabasePath,intSlashLocation)
strImagePath = strDatabasePath & strImagePath
End If
.Visible = True
.Picture = strImagePath
strResult = "Image found and displayed."
End If
End With
Exit_DisplayImage:
DisplayImage = strResult
Exit Function
Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
ctlImageControl.Visible = False
strResult = "Can't find image in the specified name."
Resume Exit_DisplayImage:
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "An error occurred displaying image."
Resume Exit_DisplayImage:
End Select
End Function
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)