Results 1 to 6 of 6
  1. #1
    hlbly1969 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2020
    Posts
    7

    Print different labels depending on Form Entry

    How do I print out 2 different labels depending on the entry of a form?
    So I have a form that request a date input which will print out a label (report) with that date printed on the label with a control number that is automatically incremented.


    If I dont require a date I just leave the date field blank on the form and then it needs to print out the second label (report) with the same control number that is automatically incremented.

    See the attached screenshot of the 2 different labels.

    Click image for larger version. 

Name:	Ctrl_Rpt_outputs.jpg 
Views:	21 
Size:	77.7 KB 
ID:	44905

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Code:
    sub btnPrint()
    if isnull(txtDate) then
       docmd.openreport "rReport2NoDate"
    else
    
    docmd.openreport "rReport1Date"
    endif end sub

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Two reports for the lack of data in one field? Many ways you could handle this; one being that the query behind the report should be all you need to handle this.
    The date field being like
    Exp.Date: IIF(IsNull(Forms!FormName.theDateField),"NONE", (Forms!FormName.theDateField). Result should be a date or "NONE" in the report.

    Could also use IF block in report load code
    IF IsNull(Me.txtDateFieldName) Then Me.txtDateFieldName = "NONE"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Or an expression in textbox: =Nz(ExpDate, "None")
    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
    hlbly1969 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2020
    Posts
    7
    To add a bit more information the control number needs to increment by 1 every time the report is printed out either with an expiration date or none.

    I use the following in the Before Update event in the form for the expiration date:

    Private Sub Exp_Date_BeforeUpdate(Cancel As Integer)
    Me.Ctrl_Nmbr = Nz(DMax("Ctrl_Nmbr", "Ctrl_Nmbrs"), 0) + 1
    End Sub

    Which when I put a date in the Exp_date field on the form then the record in the table is updated with the next control number and the date is recorded.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Then use one report as suggested and move your incrementing code to the button that opens the report.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Print only one row of labels
    By Windle in forum Forms
    Replies: 2
    Last Post: 05-10-2019, 09:24 AM
  2. Update a Table depending on Form Entry
    By carterlangley in forum Programming
    Replies: 4
    Last Post: 03-10-2018, 01:39 AM
  3. Replies: 3
    Last Post: 07-28-2014, 03:02 PM
  4. Replies: 5
    Last Post: 08-08-2012, 01:30 PM
  5. Replies: 10
    Last Post: 11-23-2010, 10:16 PM

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