Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help with Code (Access 2000)

    I have a form that I want be able to print one envelope. I have a report that is based on a query with the following criteria in the ContactID --[Forms]![Contacts]![ContactID]. Then, the code behind the command button looks like this:

    Private Sub cmbPrintEnvelop10_Click()
    On Error GoTo Err_cmbPrintEnvelop10_Click

    Dim stDocName As String

    stDocName = "rptBusinessEnvelop1Contact"
    DoCmd.OpenReport stDocName, acPreview

    Exit_cmbPrintEnvelop10_Click:
    Exit Sub

    Err_cmbPrintEnvelop10_Click:
    MsgBox Err.Description
    Resume Exit_cmbPrintEnvelop10_Click

    End Sub

    When I try and use the Command button it's prompting for the ContactID. What do I need to include in code to get this to work correctly?

    Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need Help with Code (Access 2000)

    This should work OK if the form that contains the command button cmbPrintEnvelop10 is named Contacts AND if this form contains a control named ContactID. Check carefully whether both conditions are met.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •