Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Mar 2007
    Location
    Dexter, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have command button that brings up a report. How do I create a link so it will only bring up the report tied to the customer on the form? At first I created a perimeter query but that could drive everyone crazy.

    cmdViewQuote
    Control Source: QuoteGroup

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Theresa01' post='762312' date='27-Feb-09 20:45']I have command button that brings up a report. How do I create a link so it will only bring up the report tied to the customer on the form?[/quote]

    You should have a customer ID or Number. Or any field that is unique for each record.
    Lets say that you name this field CustomerNumber. Put that field on your form and on your report. You can set the Visible property to No if you want.
    Under the click event of the button, use the following instruction :
    DoCmd.OpenReport "ReportName", acNormal, , "CustomerNumber = " & Forms!YourFormName!CustomerNumber
    Francois

  3. #3
    Star Lounger
    Join Date
    Mar 2007
    Location
    Dexter, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm afraid I've made a mess of this. I've made several format errors that if I fix now will require adjusting a lot of queries and links on forms.

    The primary key for the form is Quote Group while the primary key on the report has no space, QuoteGroup. I'll correct it if need be but first I would like to see if that is the only thing that I have wrong.

    Private Sub cmdViewQuote_Click()

    DoCmd.OpenReport "rptQuote", acNormal, , "Quote Group = " & Forms!frmProdSelect_QuoteManager!QuoteGroup

    End Sub

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Theresa01' post='762578' date='01-Mar-2009 12:01'][/quote]

    What is the type of Quote Group ? Is it Numeric or Text ?

    For Numeric it's OK.
    Code:
    DoCmd.OpenReport "rptQuote", acNormal, , "[Quote Group] = " & Forms!frmProdSelect_QuoteManager!QuoteGroup
    If it is Text you should use :
    Code:
    DoCmd.OpenReport "rptQuote", acNormal, , "[Quote Group] = '" & Forms!frmProdSelect_QuoteManager!QuoteGroup & "'"
    Francois

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    DoCmd.OpenReport "rptQuote", acNormal, , "Quote Group = " & Forms!frmProdSelect_QuoteManager!QuoteGroup
    If a field name contains a space, you should enclose the name in square brackets.
    What data type is "Quote Group" ? Is it a Number or Text?
    if a Number, you need:
    DoCmd.OpenReport "rptQuote", acNormal, , "[Quote Group] = " & Forms!frmProdSelect_QuoteManager!QuoteGroup

    If it is Text
    DoCmd.OpenReport "rptQuote", acNormal, , "[Quote Group] = " & chr(34) & Forms!frmProdSelect_QuoteManager!QuoteGroup & chr(34)
    Chr(34) is just code for ", so this just puts double quotes around the form value.
    Regards
    John



  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='johnhutchison' post='762582' date='01-Mar-2009 12:22']If a field name contains a space, you should enclose the name in square brackets.[/quote]

    Oops I forgot the square brackets. Thanks John.
    Francois

  7. #7
    Star Lounger
    Join Date
    Mar 2007
    Location
    Dexter, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It was text and that worked well. Thank you.
    I didn't realize that it was going to automatically print it out though. Unless there's another way around it, I've put together a macro to open it in print preview. Will you please tell me how to add that into the module. The macro name is mViewQuote.

    I tried this but it didn't work:

    Private Sub cmdViewQuote_Click()

    DoCmd.RunMacro "mViewQuote", acNormal, , "QuoteGroup = '" & Forms!frmProdSelect_QuoteManager![QuoteGroup] & "'"

    End Sub

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Theresa01' post='762598' date='01-Mar-2009 14:08'][/quote]
    You don't need a macro to do that. Just replace acNormal by acPreview.

    Code:
    DoCmd.OpenReport "rptQuote", acPreview, , "QuoteGroup = '" & Forms!frmProdSelect_QuoteManager!QuoteGroup & "'"
    Francois

  9. #9
    Star Lounger
    Join Date
    Mar 2007
    Location
    Dexter, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can't thank you enough!!!

Posting Permissions

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