Results 1 to 11 of 11
  1. #1
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87

    Printing report from first record works...

    I have a subform (a list of invoices for a company). I've written code so when the user dbl clicks on the Invoice Id field, in the subform, it displays the actually invoice.

    This works fine when you click on the first (top) record in the subform (datasheet). If you click on any other record in the subform, the invoice prints blank with #type! in the the address field of the report (i.e. no data).

    Why would it work on only the first record in the subform.

    DoCmd.OpenReport "rptInvoice", acViewPreview, , "[InvoiceID] In (" & InvoiceID & ")"

    I can see it passing the invoiceid to the string on the request from both the first record and the subsequent records but the report only contains data when you click on the first record.



  2. #2
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    Is InvoiceID a numeric field? Then try:

    DoCmd.OpenReport "rptInvoice", acViewPreview, , "[InvoiceID] = " & InvoiceID

    Is InvoiceID a text field? Then try:

    DoCmd.OpenReport "rptInvoice", acViewPreview, , "[InvoiceID] = " & chr(34) & InvoiceID & chr(34)

  3. #3
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    Nope it is in integer field

  4. #4
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    An integer field is a numeric field.

  5. #5
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    Can we stop debating field types. It is a number field, integer whatever the field does not contain letters. If you have an answer for why it will print the first record but not the other please feel free to respond.

    Thanks, Tina

  6. #6
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    Since InvoiceID a numeric (integer) field, please try:

    DoCmd.OpenReport "rptInvoice", acViewPreview, , "[InvoiceID] = " & InvoiceID

  7. #7
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    nope didn't work - I still only get data on the invoice if I click the first invoice number in the subform. If I click the second number(row) in the subform there is no data in the invoice (report). Is there a cache or something I need to clear?

    I just realised something new. So here is the whole process.

    Users select company from a combo box. Screen shows company info in the main form and all of the company's invoices in the subform. If I click on the Invoice Id in the second row of the subform - nothing happens. If I click on the Invoice Id in the first row of the subform it shows the invoice with the data for the invoiceid the user clicked on.

  8. #8
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    If the code above is in your InvoiceID OnDblClick event procedure, then I don't see what the problem is. Please verify that the code is there, and if it is, then please post your database so the experts here can debug the issue.

  9. #9
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87

    Here is a modified copy of the database

    Attachment 5913

    I tested the parts you need and the work just like they do in the big database .

    There is a stop in the code because I wanted to make sure it was capturing the invoiceid field.

    Tina

  10. #10
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    thanks for the file. Your invoice report is coming up with no data when certain detail records are double clicked. It doesn't have anything to do with whether the first or second record is double-clicked. Check the record source for your invoice report. I notice that it has a "having" clause that excludes data that is not from a particular date. You may want to ensure that all your invoices are available to your invoice report. Also, the record source appears to be joining Company information with invoice details instead of CompanyBilling and Invoice Details, which would seem to make more sense for an invoice report.

  11. #11
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    It's been awhile since I worked on this report - I forgot the report was set up to show only the most recent invoices. Problem fixed. I'll copy the report with a new name for access from the form. Thank you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-15-2012, 02:46 PM
  2. Printing multiple reports for one record
    By brew in forum Programming
    Replies: 3
    Last Post: 11-18-2011, 10:01 AM
  3. Replies: 0
    Last Post: 05-25-2011, 06:13 AM
  4. Printing form record issues
    By rmohebian in forum Access
    Replies: 3
    Last Post: 03-06-2011, 02:33 PM
  5. Printing the active record only
    By aligahk06 in forum Access
    Replies: 3
    Last Post: 12-02-2010, 08:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums