Results 1 to 4 of 4
  1. #1
    scotty123 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    2

    Printing An Invoice

    Hi, i have attached my db below in zip file.



    If you go to forms > jobs

    There are 2 sample jobs in the db, i have a print invoice button, when you press this i am able to capture the correct invoice number in the alert but unsure how to generate the sql for the invoice (job 999 always appears regardless )

    I've attached the code below, i've commented out the part which i had hoped would work but understand you cant run a SELECT from .RunSQL

    Basically, when the user clicks on the invoice button it should check to see which job is being viewed then populate that job info into the invoice report.

    Can someone help please!!!

    Code:
    Private Sub Command14_Click()
    
        currentInvoice = Me![Invoice Number]
        
        MsgBox "You are opening invoice number " & currentInvoice
        'DoCmd.RunSQL ("SELECT * FROM Jobs WHERE [Invoice Number]= '" & currentInvoice & "'")
    
        DoCmd.OpenReport "Invoice", acPreview, acEdit, currentInvoice
        
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Your WhereCondition needs to be a WHERE clause *without* the word WHERE:
    strCondition = "[Invoice Number] = '" & currentInvoice & "'"
    DoCmd.OpenReport "Invoice", acPreview, acEdit, strCondition

  3. #3
    scotty123 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    2
    Hi RuralGuy, thanks for taking the time to explain, i have it working now

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Thanks for posting back with your success.

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

Similar Threads

  1. Invoice for kits
    By tomasreabe in forum Access
    Replies: 1
    Last Post: 09-22-2011, 04:33 PM
  2. Add a 1.5% charge to invoice?
    By alx100 in forum Access
    Replies: 1
    Last Post: 03-16-2011, 03:18 PM
  3. Invoice number
    By slik_02 in forum Access
    Replies: 3
    Last Post: 08-08-2009, 08:05 AM
  4. Invoice
    By billyff in forum Access
    Replies: 3
    Last Post: 04-25-2009, 12:15 PM
  5. Invoice Number
    By rzwoo in forum Access
    Replies: 0
    Last Post: 02-25-2009, 01:30 AM

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