Results 1 to 11 of 11
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365

    Listbox positioning labels

    I've got 3 labels above a multi col listbox.
    Is there a formula to set their width from the list columnWidths property?
    Once known I can maybe set their Left pos as well.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Why not just use the listbox column headers property?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    You set the column widths in the listbox columnwidth property- so easy to work out. Just remember there are 1440 twips to an inch

  4. #4
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    From what I read you can't set a name for column headers , it has to be a bound control?
    So 567 tw to CM then I found all I needed was

    Me.Label2.Width = Split(Me.List0.ColumnWidths, ";")(0)
    Me.Label3.Width = Split(Me.List0.ColumnWidths, ";")(1)
    Me.Label4.Width = Split(Me.List0.ColumnWidths, ";")(2)
    Me.Label3.Left = Me.Label2.Width + Me.Label2.Left
    Me.Label4.Left = Me.Label3.Width + Me.Label3.Left

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    "can't set a name for column headers , it has to be a bound control" - don't understand this statement.

    Listbox ColumnHeaders uses field names from RowSource. If you don't want to use the native field names, use alias in RowSource SQL.

    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.

  6. #6
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    I'm sure you know June, that was something I read while looking for an answer with Google.
    This hasn't a row source though, it's just a list showing some data and one row is selected/used after clicked.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    An UNBOUND listbox certainly can have column headers - whether RowSourceType is Table/Query or Value List.

    How are you building this list?

    But why do you need dynamic code to set label positions anyway? Is this listbox content variable?
    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.

  8. #8
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    It is a value list and I'm filling it with additem. The 3 columns hold filename, bitrate and duration. These are calculated in a class module the file is sent into.
    I initially set the coordinates manually, changing the values until they were right. Then thought that is crazy, any changes to the column widths and all that had to be done again.
    Let the computer do it... and it has worked out perfectly. I suspect you may be saying none of that was neccesary but it achieved the goal. If you want to show an alternate (proper?) way, I'm all ears.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I am not saying it is proper, just possible. Some like to use listbox headers - I have used but only with listboxes used to display data, not for data selection.

    With ColumnHeaders set to Yes, first line of list will be treated as headers. Keep in mind that when activated, headers occupy row index 0.
    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.

  10. #10
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    Thanks June , that worked just as you described. Much more eloquent. I would have looked for that except for finding into to the contrary. Never believe what you read ? !!
    I could not see ColumnHeaders, only ColumnHeads and it worked ok irrespective of the setting there.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Sorry, my typing error. But you found it anyway.
    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.

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

Similar Threads

  1. Positioning subforms
    By msmithtlh in forum Forms
    Replies: 16
    Last Post: 06-19-2014, 11:54 AM
  2. Positioning the mouse pointer
    By Larry in forum Programming
    Replies: 1
    Last Post: 07-25-2013, 01:10 PM
  3. Sizing and positioning
    By 161 in forum Database Design
    Replies: 1
    Last Post: 04-09-2011, 10:52 AM
  4. form positioning
    By taylorosso in forum Forms
    Replies: 5
    Last Post: 08-23-2009, 08:00 AM
  5. Positioning Tabular Labels
    By rod147 in forum Forms
    Replies: 6
    Last Post: 07-06-2009, 11:02 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