Results 1 to 3 of 3
  1. #1
    krag is offline Medium experience
    Windows 7 32bit Access 2013
    Join Date
    May 2014
    Posts
    71

    How to set variable width property of 4 different text boxes in one line

    I am building a quotation report with 4 text boxes in each record forming a line of item with price or a comment line without price.
    Depending on the price line or comment line, I want to set the length of the item description to the maximum available width.
    I built a code as below in the 'on print' event for the detail section but it is not accepting the value and stops with error message.
    If I try to write the code in a control button from a different form, it does not work for each line but only for the top line in each page of the report printed.
    I have tried writing the code in the event procedure for header and footer as well but same problem.
    Where should I write this code to get it going properly?
    Upper part of the code is for suppressing the sub-totals in footer when not required, which is working fine.
    Problem is the bottom part which I tried at Open Form event but did not work.

    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    If Me.Code0 = "0" Or Me.Code0 = "8" Then
    Me.Code0Footer.Visible = False
    Else
    Me.Code0Footer.Visible = True
    End IfEnd Sub

    Private Sub Report_Open(Cancel As Integer)
    Dim a, b, c, d As Long
    If IsNull(Me.Qty) Then
    a = 0
    b = 0
    c = 9072
    d = 0
    Else
    If Me.Qty = 1 Then
    a = 0
    b = 680
    c = 7145


    d = 1440
    Else
    a = 1418
    b = 680
    c = 5676
    d = 1440
    End If
    End If
    Me.TotalLP.Width = d
    Me.QtySet.Width = b
    Me.ULP.Width = a
    Me.ItemDescription.Width = c
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Code to set control properties must be in Format event of the pertinent section of report.
    Format event executes only for PrintPreview or direct to printer.
    Changing property affects ALL instances of the control - it will be reflected in every record.


    Note that the Long type declaration is applied only to variable d. VBA requires each variable's type to be explicitly declared or it will default to Variant.

    Dim a As Long, b As Long, c As Long, d As Long
    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
    krag is offline Medium experience
    Windows 7 32bit Access 2013
    Join Date
    May 2014
    Posts
    71

    Thumbs up Solved

    Many thanks for the quick reply. Now it is working perfectly.

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

Similar Threads

  1. Understanding the Form width property
    By Access_Novice in forum Forms
    Replies: 5
    Last Post: 01-18-2014, 07:03 PM
  2. Export Fixed Width with No Line Breaks/Carriage Returns
    By jpfulton248 in forum Import/Export Data
    Replies: 5
    Last Post: 01-17-2014, 12:41 PM
  3. Programming Text Width in Access
    By KAR in forum Programming
    Replies: 8
    Last Post: 12-27-2013, 10:46 PM
  4. Replies: 7
    Last Post: 10-03-2011, 12:44 PM
  5. Form-Query Variable line Headers
    By Cheshire101 in forum Forms
    Replies: 2
    Last Post: 09-13-2010, 12:38 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