私は VBA の初心者で、これら 2 つのサブ プロシージャを 1 つのプロシージャに結合しようとしています。
基本的に、Access レポートに画像を追加しようとしています (2 番目のコード ブロックで、画像パスをチェック/作成しています) - データベース製品レコードから他の情報が既にチェックされています。
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim x$, y$, i%
x = ""
For i = 1 To 10
y = Me("txtOp" & i) & ""
If y > "" Then
If x > "" Then x = x & " "
x = x & "Option " & i & ": " & y
End If
Next
If x > "" Then x = CR & x
Me.txtProduct = Me.txtItem & "" & x
If Me.Adjustment Then
Me.txtShowSKU = ""
Else
Me.txtShowSKU = Me.txtSKU
End If
Dim x, y, OK%
OK = False
x = Me.txtImage & ""
If x > "" Then
y = getparm("ImagePath")
If y > "" Then
If Right$(y, 1) <> "\" Then y = y & "\"
If Left$(x, 1) = "\" And Len(x) > 1 Then x = Mid$(x, 2)
If FileExists(y & x) Then OK = True: x = y & x
End If
If OK Then
Me.imgProd.visible = True
Me.imgProd.Picture = x
Else
Me.imgProd.visible = False
End If
End If
End Sub