title: OpenArgs not passing variable to report
body: <p>I am pretty new to VBA and i'm trying to create a button on a invoice creation form that will print the invoice. The On Click event of the button should open a report and assign the Invoice ID on the form to the openargs property.</p>
  
  <pre><code>Private Sub cmdPrint_Click()
  Dim InvoiceNum As Integer
  
  If Me.Dirty Then    'Save any edits.
      Me.Dirty = False
  End If
  
  If Me.NewRecord Then 'Check there is a record to print
      MsgBox "Select a record to print"
  Else
      InvoiceNum = Me.[Invoice Number]
      DoCmd.OpenReport "Invoice", acViewPreview, , , , InvoiceNum
  End If
  End Sub
  </code></pre>
  
  <p>Then when the report opens it runs the code:</p>
  
  <pre><code>Dim InvoiceNum As Integer
  InvoiceNum = Me.OpenArgs
  </code></pre>
  
  <p>When I click the button on the form however, the Enter Parameter Box appears. Whats strange is that the the text in this box is the value of the Invoice number I want to assign to the OpenArgs Property. I cant work out how to make the value of OpenArgs the invoice number from the form.</p>
  
  <p>I'm not sure what I have done wrong and can't seem to find the answer anywhere.
  Any help would be appreciated.</p>