Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2007
    Posts
    16

    Unanswered: Prining an Invoice.

    Hi all,

    I am having some diffiulty in printing a report basiaclly i have a report based ona query where the query has a parameter ... [ Forms]![Orders]![Order id]

    When i create the print button and add the code...
    Dim stDocName As String
    stDocName = "RptTakeaway"
    DoCmd.OpenReport stDocName, acNormal

    I have tried the above and everytime i select the print button it asks for the parameter, cant it be where it can pick up the parameter from the form
    the parameter is the order id

    below is another method i tried but still to no avail, please can someone help me on this as its really taking the mick with me now.

    Thanks.


    DoCmd.OpenReport stDocName, acNormal, , "[Forms]![Orders]![Order id]=" & G_orderId

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    "[Forms]![Orders]![Order id]=" & G_orderId
    Should probably read
    Code:
    [Forms]![Orders]![Order id]"= & G_orderId"
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2007
    Posts
    16
    Hi,

    Thanks for the reply, i tried taht but it brought up an error all i am trying to do is print the report if i type in the order number in to the button when it is clicked that works fine and it prints it how i want but doesnt do that, cant it just pick up the order number and automatically put it into the paremeter when printing, as i am suing a touch screen it needs to do that i am sure it is something very easy.
    but just cant seem to figure it out :-S
    thanks

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Base the report on a query that uses your criteria..?
    George
    Home | Blog

  5. #5
    Join Date
    Nov 2007
    Posts
    16
    Hi,

    Yes i have based the report in a query and it uses the follwing criteria:
    [ Forms]![Orders]![Order id]

    This does work fine but when i into the form and code the button to print it instead of printing the current record it asks for the criterai in the parameter box thats what i dnt want i want it to print the current order.

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I believe this....

    DoCmd.OpenReport stDocName, acNormal, , "[Forms]![Orders]![Order id]=" & G_orderId

    should be....

    DoCmd.OpenReport stDocName, acNormal, , "[G_orderid] = " & [Forms]![Orders]![Order id] & ""

    (with or without the 2 end quotes) - using " for integer comparisions and ' " for string values.

    Does your parameter box which appears ask for "[Forms]![Orders]![Order ID]" or does it ask for a different parameter? If it is asking for a different parameter, it's possible that field isn't in the query or the report can't find the field it's asking for (sometimes the field can be mispelled on the report or in a grouping header/footer, etc....)

    I'm guessing the form "Orders" is open and not closed when the report is opened.

    Finding the culprit field on the report can sometimes be time consuming (i.e. it could even be a mistyped expression somewhere on the report.) If you can't find it, it might be easier to simply create a new report via the report wizard (or manually) and add in the criteria to the query for the report.

    If it's asking for [Forms]![Orders]![Order ID] then also check to make sure the Orders form has a field named "Order ID" (although I personally like to name fields without spaces.) Make sure it's a field named Order ID and not just the control source. A simple thing like a field named slightly differently (i.e. Order <space> <space> ID verses Order <space> ID) can be the culprit.
    Last edited by pkstormy; 12-04-07 at 19:39.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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