|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub UserForm_Initialize()
Dim btarr() As Byte
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim mypath As String
Dim mytable As String
Dim SQL As String
Dim tmpath As String
mypath = ThisWorkbook.Path & "\照片管理.accdb"
mytable = "照片档案"
On Error GoTo errmsg
With Sheet1
cnn.Open "provider=microsoft.ace.oledb.12.0;data source=" & mypath
SQL = "Select * From " & mytable & " Where 图片编号=" & Val(.[b1])
rst.Open SQL, cnn, adopenkeyset, adlockoptimistic
If rst.EOF Then
MsgBox .[b7] & "图片编号不存在,请重新输入", , "图片编号错误"
Else
.[b2] = rst("名称")
.[b3] = rst("编号")
.[b4] = rst("内容")
.[b5] = rst("轮次")
.[b6] = rst("零部件名称")
If IsNull(rst("照片")) Then
.Image1.Visible = False
.[c1] = "暂无照片"
Else
tmpath = ThisWorkbook.Path & "\temp.jpe"
btarr = rst("照片")
.Image1.AutoSize = False
.Image1.picturesizemode = fmPictureSizeModeStretch
f = FreeFile
Open tmpath For Binary Access Write As #f
Put #f, , btarr
Close #f
.Image1.Picture = LoadPicture(tmpath)
.Image1.Visible = True
.[c1] = ""
Kill tmpath
End If
End If
End With
Exit Sub
errmsg:
MsgBox Err.Description, , "错误报告"
End Sub
|
|