Art,
Depending on the use/purpose of the form, I expect the form should not have any record source and the combo box should not have a Control Source. If you described the intention of the form we might be able to provide a better answer.
Regards,
Duane Hookom
Sent: Monday, September 4, 2017 1:32 PM
To: 'Graham Mandeno' graham@mandeno.com [MS_Access_Professionals]
Subject: Re: RE: [MS_AccessPros] Combobox is returning wrong value
With Warm Regards,
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: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
Tidak ada komentar:
Posting Komentar