Is there a way to right align a listbox?
Is there a way to right align a listbox?
Google: access right align listbox
Check this http://sites.google.com/site/msacces...entforalistbox
I opened the project from that site in 2010 and the listboxes align only left, didn't test in 2007 yet.
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.
Ya I tried that technique which seemed to work until I run the report and the listboxes go back to left aligned. Seems kind of weird that a person can only left align in a listbox.
The only other thing I can think of is to pad the values with leading spaces or zeros. I do that with a custom function.I took another look at that sample db in 2007 and it shows the same as in 2010. In design view the listboxes show the center and right alignment but in form view all is left aligned. The video from the site clearly demonstrates the technique. The author's demo was for form not report. Simply does not work for me.Code:Private Function Pad(varText As Variant, strAlign As String, intLength As Integer) As String If Len(varText) >= intLength Then 'if the source string is longer than the specified length, return the Length left characters Pad = Left(varText, intLength) ElseIf strAlign = "L" Then 'text aligns left, fill out the right with spaces Pad = varText & String(intLength - Len(varText), " ") Else 'text aligns right, fill out the left with spaces Pad = String(intLength - Len(varText), " ") & varText End If End Function
Last edited by June7; 07-10-2011 at 03:42 PM.
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.
Ya I tried Leban's Justicombo also but it's not working using a report. anybody know of a way to make that work for a report. Works fine on a form.
I just tested Lebans code. In his demo project I built a report based on the demo form frmJustify and copied the listboxes over to the report. It works great. Did not test the code in a new project.
His code is also padding with space characters, just more sophisticated.
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.
Combos are not really good for reports as there is no real need for them as you can't select anything from them and they can only show one field while on there. Why not just use a text box instead?
@June7, i did that also but when you ran the report was the form still open? I tried it and it worked but as soon as I closed the form it didn't work in report.
@bobLarson. Can a textbox display a column of data like a listbox?
You can use text boxes formatted to look like it is a listbox. And by using separate ones you can have it justify each field the way you want it justified. All it takes is a little bit of work and formatting.
Bob, Lebans calls it Justicombo but it is for list boxes.
brc, yes the form was open and closed the values don't show. I will have to play with this some more this weekend. Using VBA can build one long string with concatenation to appear as columns and multiple rows (using vbCrLf in VBA and Chr(13) & Chr(10) in Access) but will still need a padding function. I do this for several reports.
Last edited by June7; 07-09-2011 at 12:58 AM.
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.
bob, so in your opinion what is better to do? a whole bunch of textboxes or space padded listbox?
I don't know how Lebans code would have to be modified to work for a report without the form open but I tested my little function and it did the job. I changed it to a Public function, put it in a general module and then called it in the listbox 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.
Ok Thanks June7 I will give that try
OK, June7 I have got your code to work but the original control was set to currency format which this code seems to strip. Is there a way to keep datatype as currency or do i have to add .00 and $ to each number if needed?