1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

HELP! Need to make reciept off form...?

Discussion in 'Business Applications' started by juped, Oct 20, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. juped

    juped Thread Starter

    Joined:
    Oct 3, 2007
    Messages:
    8
    OK so ive set up a data base for my buisiness and everything is fine... BUT i cant work out how on earth to do one thing. I type in a new order for example or view an order on a form, how can i go straight to a report of that order which im viewing. I want to print the information seen in that one form nothing else, basically as a reciept. please reply quickly, as database needs to be completed asap. I know i have to probably make a query but i have made many advanced databases with out using a query and got round it so could you make it REALLY clear step by step process to explain.... Thanks
     
  2. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    Not that complicated. Go to your form's design view and drag down a command button. Set it up to Form Operations, then Print Current Form. Access will write code along these lines for you (here, the button is Command35 and the form is namedCompany):
    Private Sub Command35_Click()
    On Error GoTo Err_Command35_Click

    Dim stDocName As String
    Dim MyForm As Form

    stDocName = "frmCompany"
    Set MyForm = Screen.ActiveForm
    DoCmd.SelectObject acForm, stDocName, True
    DoCmd.PrintOut
    DoCmd.SelectObject acForm, MyForm.Name, False

    Exit_Command35_Click:
    Exit Sub

    Err_Command35_Click:
    MsgBox Err.Description
    Resume Exit_Command35_Click

    End Sub
    Then, when you have entered your data into the form, go to Records, Filter, Filter by Form and select one parameter you want (company name, id, whatever field you want to use). Click the filter funnel button at the top of the page. This limits your form to printing just that. Now click the print button you added earlier. There you go!
     
  3. juped

    juped Thread Starter

    Joined:
    Oct 3, 2007
    Messages:
    8
    sorry probably made it unclear... ive built a report as a reciept and want to print from that report but just the records on that viewed form. Hope that makes sense...
     
  4. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    How many Records are shown on the Form?
     
  5. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Why print the form? Print a report based on the record number currently open on the form.
     
  6. juped

    juped Thread Starter

    Joined:
    Oct 3, 2007
    Messages:
    8
    theres a single customer record with a subform showing order records related to that record
     
  7. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    juped, I agree with Rockn, hence my question about records.
    To transfer the Form's Current Record to the Report use this VBA in your Command Button.
    Dim stDocName As String, stDocName2 As String

    stDocName = "Your Report Name"
    DoCmd.OpenReport stDocName, acViewPreview, , "[Field in Report]=" & Me![Field in Form]

    Where the Form and Report Fields are how your Record is Identified.
     
  8. juped

    juped Thread Starter

    Joined:
    Oct 3, 2007
    Messages:
    8
    you will have to talk through that.... no comprendo!
     
  9. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    Create a Command Button to open your Report in Preview mode from your Form.
    Then Copy and Paste in the Code from post #7.
    Put your Report's name in where it says "Your Report Name".
    Add the
    , , "[Field in Report]=" & Me![Field in Form]
    after the
    DoCmd.OpenReport stDocName, acViewPreview

    where it says
    Field in Report
    you put it the name of the field in your report that matches the filed in your Form, this is usually The Indexed key Field.
    where it says
    Field in Form
    you put in your Field name for the same Field that is on your form, this is also normally the Indexed Key Field.
     
  10. juped

    juped Thread Starter

    Joined:
    Oct 3, 2007
    Messages:
    8
    ok thanks.... sooooo nearly there... It all works apart from i have to type in the customer ID i want it to transfer automatically. It asks for parameter value etc etc....
     
  11. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    19,684
    Make sure that the CustomerID is on both the Form,the Report and the Query that supplies the Report.
     
  12. juped

    juped Thread Starter

    Joined:
    Oct 3, 2007
    Messages:
    8
    Dim stDocName As String, stDocName2 As String

    stDocName = "Order details1"
    DoCmd.OpenReport stDocName, acViewPreview, , "[CustomerID]=" & Me![CustomerID]

    Thats what ive got. The form & report both have the CustomerID fields. The report is built of two tables rather than a query, that make any difference?
     
  13. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    I think (OBP, correct me if I am wrong) that it should still work, but for convenience and clarity I would combine the two tables into one query (don't duplicate any fields, like CustomerID) and base the report(s) on that.
     
  14. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/640988

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice