473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access 2007 - Break up a list box into columns

8
I have a problem that I'm not sure there is a solution for... I have a lookup field in a table that allows multiple values and the display control is set to be a List Box. The list box looks fine on the form (ie. a bunch of check boxes), but there are about 15 entries that I would like to have on the screen at once (ie. no scroll bars). Is there any way to break up the list box into columns (like 4 columns of check boxes)?

I have tried changing the Column Count value but this doesn't seem to have the intended effect....
Jun 29 '07 #1
13 6620
ADezii
8,834 Expert 8TB
I have a problem that I'm not sure there is a solution for... I have a lookup field in a table that allows multiple values and the display control is set to be a List Box. The list box looks fine on the form (ie. a bunch of check boxes), but there are about 15 entries that I would like to have on the screen at once (ie. no scroll bars). Is there any way to break up the list box into columns (like 4 columns of check boxes)?

I have tried changing the Column Count value but this doesn't seem to have the intended effect....
Is your request to convert a single column List Box to a 4 Column List Box? If so is there a Delimiter betwen values in the single column List Box? What exactly are you trying to accomplish by doing this? Do you realize that the new format of the List Box will be for display purposes only? If this is your goal, please post some typical single column List Box entries.
Jun 30 '07 #2
epid
8
Is your request to convert a single column List Box to a 4 Column List Box? If so is there a Delimiter betwen values in the single column List Box? What exactly are you trying to accomplish by doing this? Do you realize that the new format of the List Box will be for display purposes only? If this is your goal, please post some typical single column List Box entries.
First of all, thanks for your reply. To answer your question, yes I would like to convert a single columns List Box to a 4 Column list box for purely formatting purposes. The List Box has about 15 entries and I don't want to have all of the items in the list box in one column. Since the List Box allows multiple selections, it does contains Check Boxes. The database is going to be used to keep track of optical prescriptions so typical entries (for tint color) would be: Clear, Grey, Pink, Yellow, etc. If this still doesn't make sense, let me know and I will create a couple screenshots.
Jul 1 '07 #3
ADezii
8,834 Expert 8TB
First of all, thanks for your reply. To answer your question, yes I would like to convert a single columns List Box to a 4 Column list box for purely formatting purposes. The List Box has about 15 entries and I don't want to have all of the items in the list box in one column. Since the List Box allows multiple selections, it does contains Check Boxes. The database is going to be used to keep track of optical prescriptions so typical entries (for tint color) would be: Clear, Grey, Pink, Yellow, etc. If this still doesn't make sense, let me know and I will create a couple screenshots.
I would have preferred a little more information, but I think I have enough to give you at least a code Template to work off of. The following code will transfer the entries in a Single-Column List Box named lstOriginal to a 4-Column List Box named lstNew. Let me know how you make out:
Expand|Select|Wrap|Line Numbers
  1. Dim intNoOfEntries As Integer, intCounter As Integer, strNew As String
  2.  
  3. 'Define the characteristics of the New List Box
  4. With Me![lstNew]
  5.   .ColumnCount = 4
  6.   .BoundColumn = 0     'doesn't matter
  7.   .RowSourceType = "Value List"
  8.   .ColumnWidths = "1 in;1 in;1 in;1.25 in"
  9.   .Width = (4.25 * 1440)   'in Twips 1 inch = 1,440 Twips
  10. End With
  11.  
  12. intNoOfEntries = Me![lstOriginal].ListCount
  13.  
  14. With Me![lstOriginal]
  15.   For intCounter = 0 To intNoOfEntries - 1
  16.     strNew = strNew & .ItemData(intCounter) & ";"       'concatenate into a String
  17.   Next
  18. End With
  19.  
  20. strNew = Left$(strNew, Len(strNew) - 1)     'remove trailing ;
  21.  
  22. Me![lstNew].RowSource = strNew              'RowSource for New List Box
Jul 1 '07 #4
epid
8
I tried the code you posted (with the listbox named appropriately) but got some weird results - strNew only contained "1;2;3;4;5;6;7" etc...

Here is a screenshot that I hope helps to clear things up a bit:

Screenshot
Jul 3 '07 #5
epid
8
Okay - using the following code, I am able to select and deselect items in the List Box using regular Check Boxes (unbound). I suppose that I can make the List Box invisible and control it using the Check Boxes. The only thing is I'm not sure if it is bad practice to have things coded like this. Any thoughts?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Check122_Click()
  2.   If (Check122.Value = True) Then
  3.     Tint.Selected(0) = True
  4.   Else
  5.     Tint.Selected(0) = False
  6.   End If
  7. End Sub
  8.  
  9. Private Sub Check123_Click()
  10.   If (Check123.Value = True) Then
  11.     Tint.Selected(1) = True
  12.   Else
  13.     Tint.Selected(1) = False
  14.   End If
  15. End Sub
  16.  
Jul 3 '07 #6
epid
8
Does that seem like a bad way to go about this?
Jul 7 '07 #7
ADezii
8,834 Expert 8TB
I tried the code you posted (with the listbox named appropriately) but got some weird results - strNew only contained "1;2;3;4;5;6;7" etc...

Here is a screenshot that I hope helps to clear things up a bit:

Screenshot
That's because you are probably retrieving data from a Bound Column rather than the data in the Column which is visible in the List Box. This was part of the additional information which I would have liked to see. Try changing Line #16 to:
Expand|Select|Wrap|Line Numbers
  1. strNew = strNew & .Column(1, intCounter) & ";"
and let me know what happens.
Jul 7 '07 #8
epid
8
I made that change, but strNew still contains "1;2;3;4;5;6;7" etc...
Here is what it looks like:

Screenshot 02

Honestly, at this point I'm ready to just hard code those values directly into the table instead of having them linked from another table. It feels wrong from a database point of view but I don't know how else I can get the form to look right...
Jul 8 '07 #9
ADezii
8,834 Expert 8TB
I made that change, but strNew still contains "1;2;3;4;5;6;7" etc...
Here is what it looks like:

Screenshot 02

Honestly, at this point I'm ready to just hard code those values directly into the table instead of having them linked from another table. It feels wrong from a database point of view but I don't know how else I can get the form to look right...
If a Check Box is selected in your Multi-Select, Single Column List Box, you want only the selected Color Names, e.g. Grey, White, etc. to appear in a new 4 Column List Box. Is this correct?
Jul 8 '07 #10
puppydogbuddy
1,923 Expert 1GB
I made that change, but strNew still contains "1;2;3;4;5;6;7" etc...
Here is what it looks like:

Screenshot 02

Honestly, at this point I'm ready to just hard code those values directly into the table instead of having them linked from another table. It feels wrong from a database point of view but I don't know how else I can get the form to look right...

I think you are barking up the wrong tree ....I mean control (LOL). You need to use a ListView control to accomplish what you want. Depending on what display option is selected, the ListView expands/collapses from one to five columns. Also, the standard Listbox that comes with MS Access does not have the properties to be able to dynamically format or sort the list items, or allow for images.


Go into the design mode of a form.. click on Insert from the toolbar, then select "ActiveX Control..." from the sub menu. In the selection box that is presented, scroll down to the entry that reads "Microsoft ListView Control, Version 6.0" and click on this, then click on OK, and set the control properties.

See these links for more detailed info and sample code.
http://support.microsoft.com/kb/210006

http://www.thescripts.com/forum/thread206631.html

http://www.tek-tips.com/faqs.cfm?fid=5329
Jul 8 '07 #11
epid
8
If a Check Box is selected in your Multi-Select, Single Column List Box, you want only the selected Color Names, e.g. Grey, White, etc. to appear in a new 4 Column List Box. Is this correct?
I'm sorry - I don't think I clearly described what I wanted in the first place. At the moment, I have one Multi-Select, Single Column List Box.

All I want is to have the Single Column List Box be a Multi Column List Box so that I can see all of the items in the List Box without scrolling.
Jul 8 '07 #12
ADezii
8,834 Expert 8TB
I'm sorry - I don't think I clearly described what I wanted in the first place. At the moment, I have one Multi-Select, Single Column List Box.

All I want is to have the Single Column List Box be a Multi Column List Box so that I can see all of the items in the List Box without scrolling.
Assuming that it could be done, it would make no sense converting your Single Column. Multi-Select List Box to a Multi-Column List Box. You would loose you Multi-Select capability, and if your chose a Row in the Multi-Column version, which value in which Column would you want returned? Suppose you wanted 2 values selected in the same Row - couoldn't be done. For viewing purposes only, you could create a 2nd List Box (Multi-Column), based on the same RowSource as the Single Column. The code has already been shown providing this functionality. I'm sorry, but this is the best explanation that I can provide.
Jul 8 '07 #13
epid
8
Thanks again for all of your help. I will either hide the Listbox and use the code written in post #6 or just hard code the list into the table and use regular check boxes.
Jul 9 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
26
by: Chris Potter | last post by:
Hello everyone. I am taking my first course in C and in one of my assignments i need to print out an array that could have anywhere from 0 to 100 positive integers in it (a negative integer is...
2
by: | last post by:
Hello All, I am having a lot of difficulty trying to bind a templated column, that is programmatically created for a datagrid, to a datasource column. I have a datasource containing 2 columns,...
49
by: Allen Browne | last post by:
If you are looking for opinon on what's useful in Access 2007, there's a new article at: http://allenbrowne.com/Access2007.html Covers what's good (useful features), what's mixed (good and bad),...
1
by: Stephen B. Burris Jr. | last post by:
I am currently writing an application in Access 2003. For the reports, I have to use columns a lot. To get the report to look the way I want, I have to use the Across then Down options, because...
2
by: jafastinger | last post by:
I have a large union. If I break it into its individual parts they all run quick. The longest is the last select it takes 2 minutes to fetch all rows. When I run the query below it does not...
5
by: lgeastwood | last post by:
I have a weird problem in Access 2007. I've been working in A07 for about 2 weeks when this thing began occurring. I'm working in the VB Code Editor and set break points for event procedures....
3
by: Bobby | last post by:
Hi Can anybody tell me why the VBA code below works fine in Access 2003 but doesn't work in Access 2007? I do not get any error message, even if I put a deliberate error into the code. Also, if I...
2
by: evenlater | last post by:
I realize that user level security is not available for Access databases in the new AK27 format .accdb, and I know that I can still utilize ULS by making my database an .mdb file. But I'm...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.