title: MS Access / VBA Code: How to combine these 2 procedures
body: <p>I'm a VBA novice trying to combine these two sub procedures into a single procedure - can anyone provide how to do this? </p>
  
  <p>Basically, I'm trying to add an image to an Access report (in the 2nd code block - it's checking/creating the image path) - where there is already a check for other information from the database product record.</p>
  
  <pre><code>Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  
  Dim x$, y$, i%
  
  x = ""
  For i = 1 To 10
      y = Me("txtOp" &amp; i) &amp; ""
      If y &gt; "" Then
          If x &gt; "" Then x = x &amp; "  "
          x = x &amp; "Option " &amp; i &amp; ": " &amp; y
      End If
  Next
  If x &gt; "" Then x = CR &amp; x
  Me.txtProduct = Me.txtItem &amp; "" &amp; x
  
  If Me.Adjustment Then
      Me.txtShowSKU = ""
  Else
      Me.txtShowSKU = Me.txtSKU
  End If
  
  
  
  Dim x, y, OK%
  OK = False
  x = Me.txtImage &amp; ""
  If x &gt; "" Then
      y = getparm("ImagePath")
      If y &gt; "" Then
          If Right$(y, 1) &lt;&gt; "\" Then y = y &amp; "\"
          If Left$(x, 1) = "\" And Len(x) &gt; 1 Then x = Mid$(x, 2)
          If FileExists(y &amp; x) Then OK = True: x = y &amp; 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
  </code></pre>