Custom Column Heads.
Mihail 759 512MB Hello again ! Is it possible to have custom Column Heads in a ListBox (ComboBox) ? I have a ListBox bounded to a table (if necessary I can bound it to a query). One field (or ListBox column) is for prices. This prices (all of them) can be either in European money (Euro) either in Romanian money (Lei). If the prices use Euro or Lei, is the user choice and, of course, this information is stored somewhere in the database. So, is it possible to have custom head for the column in my ListBox like "Price [Euro]" if Euro is used or "Price [Lei]" if Lei is used ? Thank you ! Jun 2 '13 #1 Follow Post Reply 6 21532 TheSmileyCoder 2,321 Expert Mod 2GB I have not looked much into this, but I believe the only way you can change the headings of a combo/listbox is to Use Alias (as) in the underlying SQL for the query AND the field from the table must have no caption property set, or the caption will overrule the field name. The combo/listbox must also be set to use field names as headers. I know of no other method, but then again,I haven't tried to research it either. Jun 2 '13 #2 reply Mihail 759 512MB Thank you, Smiley. I know about Alias, but is not what I am looking for because is STATIC. I am looking for PROGRAMMABLE column heads, that means DYNAMIC column heads. Hope you can understand what I mean, beyond my poor English. In the other words I wish to define the column heads in terms like this: Expand|Select|Wrap|Line Numbers
Jun 3 '13 #3 reply Oralloy 983 Expert 512MB Mihail, Try looking at the ListBox Columns in the debugger watch window. Is there a property that carries the header text in it? If so, can you affect that property, or is it read-only? Cheers, Oralloy Jun 3 '13 #4 reply TheSmileyCoder 2,321 Expert Mod 2GB Hi Mihail. The rowsource of a listbox is not static. You can dynamically change the rowsource through VBA. Note that any change of rowsource also triggers a requery, so if the listbox contains many records, or the connection is slow, this might not be acceptable. Expand|Select|Wrap|Line Numbers
Expand|Select|Wrap|Line Numbers
Jun 3 '13 #5 reply zmbd 5,400 Expert Mod 4TB Quite simply, using the built-in listbox control T.S.C. has the correct answer... Now you can attempt to change the caption of the underlying query field, alter the alais, etc.. ; however, I personally haven't tried this so I don't know if such would work for what you are after. : ListBox.ColumnHeads Property (Access)Office 2013 (2010) The RowSourceType property specifies whether field names or the first row of data items are used to create column headings. If the RowSourceType property is set to Table/Query, the field names are used as column headings. If the field has a caption, then the caption is displayed. For example, if a list box has three columns (the ColumnCount property is set to 3) and the RowSourceType property is set to Table/Query, the first three field names (or captions) are used as headings. Jun 3 '13 #6 reply Mihail 759 512MB Thank you (all of you) for trying to find a solution. The answer to my question is not something which burn me. I can use custom captions for labels instead the custom column heads. Only I am wonder if it is possible to have programmable column heads for a ListBox (or ComboBox). @Oralloy Of course I can't find a property like this. It is why I ask here. I post a pseudo-code because my English is not very good. @Smiley It is not about the row source. It is about the column head(s) only. Sorry (again) for my poor English. @ZMBD As I say (#1) my ListBox is bounded. So, "the field names are used as column headings" (or the field caption if exist). @You, ALL I know that I can accomplish this task if I use SQL in VBA: Expand|Select|Wrap|Line Numbers
Thank you, again, for yours time ! Jun 4 '13 #7 reply
Post your replySign in to post your reply or Sign up for a free account. Post Reply Similar topics
|