Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2012
    Posts
    126

    Unanswered: Print report based on current form open

    I created an order entry database for some users at work. I created a main form that has customerName, customerAddress, zip, state which drives an orderID and orderDetails table. I have a subform attached that shows Item#, Description and Qty.

    I need to make a print button that will print a report based on the information the user entered. How do I make the button print a report based on the current data in that form? Do I use the forms sql code as the forms control source?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The first step consists in creating a report based on the same data source (table or query) as the form. Then you can use the OpenReport method of the DoCmd object to open the report, using the WhereCondition (4th) parameter to filter the data set of the report:
    Code:
    .OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
    Have a nice day!

  3. #3
    Join Date
    Aug 2012
    Posts
    126
    sweet thank you! Will this work if i create a report with a subreport similar to my form? And out of curiosity what would I use for my where condition? I used access help but they don't really have any examples there.

    This is the sql for my form:


    Quote Originally Posted by Syrch View Post
    SELECT tblOrderNumbers.OrderID, tblOrderNumbers.OrderDate, tblOrderNumbers.CustomerID, tblTraderJoeAccounts.Address, tblTraderJoeAccounts.City, tblTraderJoeAccounts.State, tblTraderJoeAccounts.Zip
    FROM tblTraderJoeAccounts INNER JOIN tblOrderNumbers ON tblTraderJoeAccounts.CustomerNumber = tblOrderNumbers.CustomerID;


    And this is for my subform:

    SELECT tblOrderDetails.OrderID, tblOrderDetails.TraderJoeItemNumber, tblTraderJoeItemNumbersWithDescription.ItemNumber, tblTraderJoeItemNumbersWithDescription.Description , tblTraderJoeItemNumbersWithDescription.PK, tblTraderJoeItemNumbersWithDescription.Size, tblOrderDetails.CasesOrdered
    FROM tblTraderJoeItemNumbersWithDescription INNER JOIN tblOrderDetails ON tblTraderJoeItemNumbersWithDescription.[TraderJoesItemNumber] = tblOrderDetails.[TraderJoeItemNumber];

    I created a main report with:

    Quote Originally Posted by Syrch View Post
    SELECT tblOrderNumbers.OrderID, tblOrderNumbers.OrderDate, tblOrderNumbers.CustomerID, tblTraderJoeAccounts.Address, tblTraderJoeAccounts.City, tblTraderJoeAccounts.State, tblTraderJoeAccounts.Zip
    FROM tblTraderJoeAccounts INNER JOIN tblOrderNumbers ON tblTraderJoeAccounts.CustomerNumber = tblOrderNumbers.CustomerID;

    And my subreport with:


    SELECT tblOrderDetails.OrderID, tblOrderDetails.TraderJoeItemNumber, tblTraderJoeItemNumbersWithDescription.ItemNumber, tblTraderJoeItemNumbersWithDescription.Description , tblTraderJoeItemNumbersWithDescription.PK, tblTraderJoeItemNumbersWithDescription.Size, tblOrderDetails.CasesOrdered
    FROM tblTraderJoeItemNumbersWithDescription INNER JOIN tblOrderDetails ON tblTraderJoeItemNumbersWithDescription.[TraderJoesItemNumber] = tblOrderDetails.[TraderJoeItemNumber];
    i saw there is an openargs function but im not exactly sure how to use it if thats what i'd even use.

    Thank you in advance for any help
    Last edited by Syrch; 09-22-12 at 12:10.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    This site explains how to print the Current Record:

    Reports: Print only the current record to a report

    The RunID, in the code, has to be a Field that is unique to that one Record.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Aug 2012
    Posts
    126
    Quote Originally Posted by Missinglinq View Post
    This site explains how to print the Current Record:

    Reports: Print only the current record to a report

    The RunID, in the code, has to be a Field that is unique to that one Record.

    Linq ;0)>
    LOL Linq im going to run out of beer! Thanks again works like a charm

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I'll start running a tab for you!

    Glad we could help, again!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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