Results 1 to 9 of 9
  1. #1
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202

    Continuous Form with adjustable columns

    Good morning,
    I have a continuous form I would like the end user to have the option to adjust the column width based on need. I did some looking around the internet and found the following from Lauren Quantrell:


    On a continuous form, in the Form Header section, between two heading
    labels, create a box with the height equalling the header height and
    the width = 0.1576". Name this box BoxColumn1.
    Create two text boxes named LeftColumName and RightColumName
    Rename the labels for these text boxes to LeftColumLabel and


    RightColumLabel

    Add this code to the OnMouseMove event of BoxColumn1:

    Code:
    'START CODE
    ************************************************** ***************************************
    Private Sub BoxColumn1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim intLeftButton   As Integer
    Dim ColumOneAdjust  As Integer
    Dim ColumTwoAdjust  As Integer
    
    
    intLeftButton = Button And acLeftButton
    ColumOneAdjust = 60
    ColumTwoAdjust = 800
    
    
    ' as you move over the box, the pointer will change to the left-right
    Size arrows:
    Screen.MousePointer = 9
    
    
    ' only if you click the left mouse button will you're over BoxColumn1 will it size, otherwise just pass over the box:
        If intLeftButton 0 Then 'Here is where I am getting the error
             'now calculate all the sizes:
            If (Me.BoxColumn1.Left + X) - ColumOneAdjust > Me.LeftColumName.Left + ColumTwoAdjust And Me.BoxColumn1.Left + X < Me.ContactsType.Left - 1200 Then
                Me.BoxColumn1.Left = Me.BoxColumn1.Left + X
                Me.BoxColumn1Row.Left = Me.BoxColumn1.Left
                Me.LeftColumName.Width = (Me.BoxColumn1.Left - Me.LeftColumName.Left) - 100
                Me.LeftColumLabel.Width = Me.LeftColumName.Width
                Me.RightColumName.Width = Me.ContactsType.Left - (Me.RightColumName.Left + 60)
                Me.RightColumName.Left = Me.BoxColumn1.Left + 60
                Me.RightColumLabel.Left = Me.RightColumName.Left
                Me.RightColumLabel.Width = Me.RightColumName.Width
            End If
        End If
    End Sub


    I am getting an error on the line
    If intLeftButton 0 Then. I understand why and it is an integer and there is no criteria. Ideas?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,566
    Add = for intbutton = 0 as it is not boolean.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202
    I tried If intLeftButton =0 Without success
    also tried >, and <, and <>.

    All make the error go away but the code isn't working.

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    @CJ_London also has code to do this.
    Hopefully he will get this alert and respond
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,566
    I was just trying to correct the syntax. I have the same idea as you as to how it works, that is Nil
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202
    After making the correction of =0 and adjusting my form, it is now workable. Have to make a few changes and still working on it, but =0 did correct the error I was getting. Thanks for the help!

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    I do have similar code but works off the header labels rather than separate controls between with labels and handles all columns, not just two

    As already pointed out the code was missing the =

    Not sure what Me.ContactsType is doing in there, perhaps a typo?

  8. #8
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202
    I am really stumped. Not proficient in VBA and trying to understand this code. I am not sure If I have the boxes in the wrong location or am not reading it correctly. Can someone review and give me some insight. I am attaching an example.

    ContinuousFormColumnAdjust.zipContinuousFormColumnAdjust.zip

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    not sure what you are trying to achieve since you have not set it up correctly as far as I can see

    your box column has a label to the left called RightColumLabel (which I would expect to be on the right) and the label to the right is called lblVersionNumber, whilst your label called LeftColumLabel is on the far left

    Then as mentioned before, you have the mysterious Me.ContactsType control which I do not see in this form

    Your code errors on this line

    If (Me.BoxColumn1.Left + X) - ColumOneAdjust > Me.LeftColumName.Left + ColumTwoAdjust And Me.BoxColumn1.Left + X < Me.PageID.Left - 1200 Then
    because Me.PageID does not exist

    and if typed correctly would generate a negative number which I'm pretty sure is not what is expected

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

Similar Threads

  1. Replies: 6
    Last Post: 08-25-2017, 02:39 PM
  2. Replies: 5
    Last Post: 02-02-2015, 03:41 PM
  3. Replies: 2
    Last Post: 01-01-2014, 02:10 PM
  4. Listbox adjustable columns
    By chook in forum Access
    Replies: 4
    Last Post: 03-07-2013, 03:41 AM
  5. Programming Adjustable Pricing Fees
    By JDA2005 in forum Programming
    Replies: 2
    Last Post: 07-07-2009, 10:50 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