Solved Resizeable column width in listbox in access (1 Viewer)

Ihk

Member
Local time
Today, 19:57
Joined
Apr 7, 2020
Messages
280
Looking for a way to have resizeable column width in listbox or continuous form or continuous subform.
It will be exactly like datasheet columns which are expandable, though I can use that datasheet but I dont want to use filter, the way datasheet works.
I will use clickable header to sort ascending or descending.
But again I am afraid it will be a problem in listbox, if i dont use built-in header labels, then my custom headers probably will not expand with respective column of list box.

I know then the best way will be use listview instead of listbox that does everything what I want but its learning curve it difficult as well as it crashes application.
for example I want like this
Before (look at column width)
1668421126850.png

After (look at column width)
1668421181474.png


Does any one has such experience, any sample database will be perfect. Thank you
I know a very old link, which was also discussed on a thread here....
ListBoxColumnResize (lebans.com)
but unfortunately, I could not try this because version of database is very old and is not compatible with any of my system.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:57
Joined
May 7, 2009
Messages
19,245
here i converted to A2007, you can then read the db.
 

Attachments

  • ResizeListboxColumn_2007.accdb
    468 KB · Views: 140

Gasman

Enthusiastic Amateur
Local time
Today, 18:57
Joined
Sep 21, 2011
Messages
14,310
Here is the Lebans DB as an accdb.
 

Attachments

  • ResizeColumnsVer15.zip
    67.7 KB · Views: 137

cheekybuddha

AWF VIP
Local time
Today, 18:57
Joined
Jul 21, 2014
Messages
2,280
With all the versions (Leban's and mine) you will have to update the API declarations to handle 64bit.
 
  • Love
Reactions: Ihk

Ihk

Member
Local time
Today, 19:57
Joined
Apr 7, 2020
Messages
280
I have attached version created by @cheekybuddha and posted on posted on UtterAccess.com.
1)
How to tackle with headings, because inbuilt headings in listbox are not embossed like my above pictures. Therefore I use custom heading with vba clickable to have ascending Descending sort function.
In this If I add custom headings, then those will not resize.
2) compatibility with 64bit version
Thank you
 

Attachments

  • ListBoxResizeCols2K.mdb
    320 KB · Views: 126

Gasman

Enthusiastic Amateur
Local time
Today, 18:57
Joined
Sep 21, 2011
Messages
14,310
Yes it very nice, but it does not work on 64bit.
Stop wanting everything handed on a plate and do some of the work yourself. :(

You are always going to have this issue if you keep using 64bit Access, so may as well get used to it and start learning how to convert to 64bit.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:57
Joined
Feb 19, 2013
Messages
16,615
you need to modify the api's to use ptrSafe and longPtr

see this file and keep it to hand for 64bit API declarations
 

Attachments

  • Win32API_PtrSafe.TXT
    676 KB · Views: 107
  • Love
Reactions: Ihk

Ihk

Member
Local time
Today, 19:57
Joined
Apr 7, 2020
Messages
280
With all the versions (Leban's and mine) you will have to update the API declarations to handle 64bit.

Stop wanting everything handed on a plate and do some of the work yourself. :(

You are always going to have this issue if you keep using 64bit Access, so may as well get used to it and start learning how to convert to 64bit.
you are right... and it should be the case. but...
 

Ihk

Member
Local time
Today, 19:57
Joined
Apr 7, 2020
Messages
280
you need to modify the api's to use ptrSafe and longPtr

Declare PtrSafe Function GetScrollPos Lib "user32" (ByVal hwnd As LongPtr, ByVal nBar As Long) As Long
Declare PtrSafe Function GetScrollRange Lib "user32" (ByVal hwnd As LongPtr, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long
Declare PtrSafe Function GetFocus Lib "user32" Alias "GetFocus" () As LongPtr
thank you very much
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:57
Joined
May 21, 2018
Messages
8,529
Does not seem to stable for me. Just crashes.
 

cheekybuddha

AWF VIP
Local time
Today, 18:57
Joined
Jul 21, 2014
Messages
2,280
1)
How to tackle with headings, because inbuilt headings in listbox are not embossed like my above pictures. Therefore I use custom heading with vba clickable to have ascending Descending sort function.
In this If I add custom headings, then those will not resize.
It's more tricky because now you are dealing with multiple objects, not just a single listbox.

What happens if you extend the size of the columns so the total width is greater than the width of the listbox?

Do you want to expand the listbox as well?

Or do you want to hide the headings which should disappear when the horizontal scrollbar appears?

Also, you need to move the headings with the scrollbar if there is one.

Suddenly it is a lot more coding. Not impossible, but you must work out exactly what you want to happen in each situation.

It is much simpler to use a datasheet - what is your problem with that method? You said something about filtering. Can you not just prevent the filtering?
 

Ihk

Member
Local time
Today, 19:57
Joined
Apr 7, 2020
Messages
280
It's more tricky because now you are dealing with multiple objects, not just a single listbox.

What happens if you extend the size of the columns so the total width is greater than the width of the listbox?

Do you want to expand the listbox as well?

Or do you want to hide the headings which should disappear when the horizontal scrollbar appears?

Also, you need to move the headings with the scrollbar if there is one.

Suddenly it is a lot more coding. Not impossible, but you must work out exactly what you want to happen in each situation.

It is much simpler to use a datasheet - what is your problem with that method? You said something about filtering. Can you not just prevent the filtering?
Yes it will be complicated, expanding of listbox etc as well, which is not required then.
Yest the best is datasheet the way they work, I like.

The only points I was wondering, that in datasheet it may not be possible.
1) Preventing of filtering
2) Header clicks to sort DESC / ASC
If these point are possible in datasheet, then it is the perfect solution.

As for continuous forms I add on click code on header of each column to sort.
Because working with datasheet is different topic (than this thread) then I should do research about this.
Thank you.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:57
Joined
Feb 19, 2013
Messages
16,615
The only points I was wondering, that in datasheet it may not be possible.
1) Preventing of filtering
2) Header clicks to sort DESC / ASC
just set the datasheet form shortcut menu property to No
 
  • Love
Reactions: Ihk

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:57
Joined
May 21, 2018
Messages
8,529
just set the datasheet form shortcut menu property to No
But, that way you lose the ability to sort. Just set Allow Filters to No
filter.jpg
 

Attachments

  • FrmAsListbox.accdb
    552 KB · Views: 113
Last edited:
  • Like
Reactions: Ihk

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:57
Joined
May 7, 2009
Messages
19,245
not related, but do you want a non-api, listbox column resizer.
the catch is that it has "handles" to resize the column.
i will put this on sample db section.
 

Attachments

  • MyRezeListboxColumns.accdb
    512 KB · Views: 121

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:57
Joined
May 7, 2009
Messages
19,245
there is one more, this time there are Labels on top of the listbox which you can resize.
completely no API.
 

Attachments

  • MyListColumnResize.accdb
    564 KB · Views: 175
  • Love
Reactions: Ihk

Users who are viewing this thread

Top Bottom