Results 1 to 5 of 5
  1. #1
    LukeSept is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2015
    Location
    Norway
    Posts
    6

    Print report based on the checkbox selection

    Hi, I'm having difficulties with building a printing option for specific goods selected on the list.



    I have a form which contains a subform. On the main form user is able to select supplier and based on the supplier can choose article that he's interested in. On the subform user gets the list of all the goods that are connected with that specific article.

    I want be able now to select specific goods from subform list (using checkbox value) and based on the selection print a separate label for each goods.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    The checkbox must be bound to a Yes/No field. Then code to open report:

    DoCmd.OpenReport "report name", , , "fieldname=True"

    Then probably need to set the field back to False for all records.

    CurrentDb.Execute "UPDATE tablename SET fieldname = False"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    LukeSept is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2015
    Location
    Norway
    Posts
    6
    Thanks for so fast answer

    Yet it solve only part of my problem. It finally prints out my report but it prints all the records not just the one selected by the checkboxes. And before printing it asks me about parameter value.

    So my current code looks like that right now:

    Code:
    Private Sub Print_Click()Dim strDefaultPrinter As String
    
    
    ' get current default printer.
    
    
    strDefaultPrinter = Application.Printer.DeviceName
    
    
    ' switch to printer of your choice:
    
    
    Set Application.Printer = Application.Printers("CutePDF Writer")
    
    
    Me.Recalc
    
    
    DoCmd.OpenReport "Labels", , , "PrintChk=True"
    
    
    'Here i tried to count selected checkboxes and print report form them
    
    
    'If Me!txtCount = 0 Then
    
    
    'MsgBox "Select a record to print.", vbOKOnly, "Error"
    
    
    'Else
    
    
    'DoCmd.Close acReport, "Labels", acSaveNo
    
    
    'End If
    
    
    ' Switch back to original default printer
    
    
    Set Application.Printer = Application.Printers(strDefaultPrinter)
    
    
    Exit Sub
    
    
    End Sub

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    As I said, the checkbox must be bound to a field - and that field must be in the report RecordSource.

    Really don't know your db well enough to give specific advice. If you want to provide for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    LukeSept is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Oct 2015
    Location
    Norway
    Posts
    6
    Damm, thank you mate it works like a charm I have put a wrong value into a fieldname ... SOLVED

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

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2015, 10:26 PM
  2. Replies: 2
    Last Post: 10-28-2014, 03:55 AM
  3. Print Checkbox on report only if checked
    By azhar2006 in forum Reports
    Replies: 5
    Last Post: 10-26-2014, 11:59 PM
  4. Replies: 5
    Last Post: 02-06-2014, 02:25 PM
  5. Replies: 3
    Last Post: 10-31-2011, 04:54 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