Senin, 04 September 2017

RE: [MS_AccessPros] Combobox is returning wrong value

 

Hello Art

What is the ControlSource for your combo box? The .Value of the combo box will be written into the ControlSource field if the combo is bound.  Your BoundColumn is 1, so the .Value of the combo box will be the first (left-most) column – i.e. the ConfigID.

Note that BoundColumn starts numbering from 1, whereas all other properties which refer to columns (ItemData, Column, etc) start numbering from 0 – confusing, eh?

Note also that the BoundColumn is not necessarily the displayed column.  The column you see when the combo box is not dropped down is the first column that does not have a zero column width.  Your ColumnWidths property is 0;1 (presumably inches) so ConfigID will be hidden and ConnectionName will be displayed.

One useful tip about combos is that any columns without a specified width will have the remaining unallocated space divided evenly.  For example, if you have 3 columns: CityID, CityName, and State, and the ListWidth is 3 inches, then you can set ColumnWidths to 0";;0.5" (note the two ;;).  This means, when the combo is dropped down, the state will be the right-hand half-inch, and the city name will occupy the remaining space (2.5").  Most of my combos have only two columns – a hidden bound one, and a displayed one.  Simply setting ColumnWidths to 0; allows the displayed column to occupy the whole combo box, and you can change the width of the control without messing about with ColumnWidths.

Best wishes,
Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Tuesday, 5 September 2017 05:47
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Combobox is returning wrong value

 

 

I have a form called frmChangeDatabase and on it I have cboDatabase with the following record source:

 

SELECT tblConfig.ConfigID, tblConfig.ConnectionName FROM tblConfig;

 

Column Count 2

Bound Column 1

Column Width : 0;1

 

There is no code behind the form at all but when you click the scroll down and select another record, Close the form and go back into it is overwriting the ConnectionName with the ConfigID and that totally confuses me.

 

Thank you,

 

Art Lorenzini

SD

__._,_.___

Posted by: "Graham Mandeno" <graham@mandeno.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar