|  | Combo selection always the 1st ? |  | |
| | | Wayne-I-M |  |
| Posted: Tue Sep 23, 2008 1:40 pm Post subject: Combo selection always the 1st ? |  |
Hi
I have an unbound combo [EventCodesCombo] that displayes a filter list of items.
SELECT [qryEventSorter].[EVTCode] FROM [qryEventSorter];
After update this combo sets the value of another combo
cboEvent = EventCodesCombo.ItemData(0)
The combo [EventCodesCombo] always reverts to the 1st item which ever is selected.
Any ideas ?
Thank you
-- Wayne Manchester, England. |
| |
| | | Jeff Boyce |  |
| Posted: Tue Sep 23, 2008 3:48 pm Post subject: Re: Combo selection always the 1st ? |  |
| |  | |
Wayne
If I'm reading your description correctly, you're telling Access to set the cboEvent to the first item in the list of items in [EventCodesCombo]. When you use .ItemData(0), that's what you're telling Access.
If you want cboEvent to be the item selected in [EventCodesCombo] (though I don't understand why you'd set a second combobox to be the value of the item selected in the first), you could use:
cboEvent = [EventCodesCombo]
Regards
Jeff Boyce Microsoft Office/Access MVP
"Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message news:14A122A4-4F70-41D5-9E80-3AECB46A27D1@microsoft.com...
| Quote: | Hi
I have an unbound combo [EventCodesCombo] that displayes a filter list of items.
SELECT [qryEventSorter].[EVTCode] FROM [qryEventSorter];
After update this combo sets the value of another combo
cboEvent = EventCodesCombo.ItemData(0)
The combo [EventCodesCombo] always reverts to the 1st item which ever is selected.
Any ideas ?
Thank you
-- Wayne Manchester, England.
|
|
| |
| | | Ken Sheridan |  |
| Posted: Tue Sep 23, 2008 4:02 pm Post subject: RE: Combo selection always the 1st ? |  |
Wayne:
Zero is the index value for the first row in a combo box's list. To refer to the currently selected row via the ItemData property you'd need to pass the current ListIndex value to the ItemData property, e.g.
With Me.ActiveControl Me.cboEvent = .ItemData(.ListIndex) End With
However, all you need to do is assign the Value of the combo box to the other control:
Me.cboEvent = Me.ActiveControl
Ken Sheridan Stafford, England
"Wayne-I-M" wrote:
| Quote: | Hi
I have an unbound combo [EventCodesCombo] that displayes a filter list of items.
SELECT [qryEventSorter].[EVTCode] FROM [qryEventSorter];
After update this combo sets the value of another combo
cboEvent = EventCodesCombo.ItemData(0)
The combo [EventCodesCombo] always reverts to the 1st item which ever is selected.
Any ideas ?
Thank you
-- Wayne Manchester, England.
|
|
| |
| | | Wayne-I-M |  |
| Posted: Tue Sep 23, 2008 4:25 pm Post subject: Re: Combo selection always the 1st ? |  |
| |  | |
Thanks Jeff - don't know why I did that - must be getting stupid in my old age :-)
Oh - the reason for the wierd passing of the combo to the 2nd is that this is a touch screen application and it was the only way I could reduce the number of controls on the screen - which I needed to do as all the controls on the form are around 3cm square.
Many thanks again-- Wayne Manchester, England.
"Jeff Boyce" wrote:
| Quote: | Wayne
If I'm reading your description correctly, you're telling Access to set the cboEvent to the first item in the list of items in [EventCodesCombo]. When you use .ItemData(0), that's what you're telling Access.
If you want cboEvent to be the item selected in [EventCodesCombo] (though I don't understand why you'd set a second combobox to be the value of the item selected in the first), you could use:
cboEvent = [EventCodesCombo]
Regards
Jeff Boyce Microsoft Office/Access MVP
"Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message news:14A122A4-4F70-41D5-9E80-3AECB46A27D1@microsoft.com... Hi
I have an unbound combo [EventCodesCombo] that displayes a filter list of items.
SELECT [qryEventSorter].[EVTCode] FROM [qryEventSorter];
After update this combo sets the value of another combo
cboEvent = EventCodesCombo.ItemData(0)
The combo [EventCodesCombo] always reverts to the 1st item which ever is selected.
Any ideas ?
Thank you
-- Wayne Manchester, England.
|
|
| |
| | | Wayne-I-M |  |
| Posted: Tue Sep 23, 2008 4:26 pm Post subject: RE: Combo selection always the 1st ? |  |
| |  | |
Thanks Ken - spotted my mistake again. Mind block when you sit here all day doing "simple" stuff the basics fly out of your head somewhere :-)
Thanks again - your answer (and Jeff's) worked perfectly
-- Wayne Manchester, England.
"Ken Sheridan" wrote:
| Quote: | Wayne:
Zero is the index value for the first row in a combo box's list. To refer to the currently selected row via the ItemData property you'd need to pass the current ListIndex value to the ItemData property, e.g.
With Me.ActiveControl Me.cboEvent = .ItemData(.ListIndex) End With
However, all you need to do is assign the Value of the combo box to the other control:
Me.cboEvent = Me.ActiveControl
Ken Sheridan Stafford, England
"Wayne-I-M" wrote:
Hi
I have an unbound combo [EventCodesCombo] that displayes a filter list of items.
SELECT [qryEventSorter].[EVTCode] FROM [qryEventSorter];
After update this combo sets the value of another combo
cboEvent = EventCodesCombo.ItemData(0)
The combo [EventCodesCombo] always reverts to the 1st item which ever is selected.
Any ideas ?
Thank you
-- Wayne Manchester, England.
|
|
| |
| | | Klatuu |  |
| Posted: Tue Sep 23, 2008 5:07 pm Post subject: Re: Combo selection always the 1st ? |  |
If I understand your question, Wayne, you are explicitly assigning the first value in the combo regardless of what is actually selected: cboEvent = EventCodesCombo.ItemData(0) The ItemData property returns the value of the bound column in the list. It is much like a collection or an array. ItemData(0) will always return the first row.
I think all you really need is:
cboEvent = EventCodesCombo
"Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message news:14A122A4-4F70-41D5-9E80-3AECB46A27D1@microsoft.com...
| Quote: | Hi
I have an unbound combo [EventCodesCombo] that displayes a filter list of items.
SELECT [qryEventSorter].[EVTCode] FROM [qryEventSorter];
After update this combo sets the value of another combo
cboEvent = EventCodesCombo.ItemData(0)
The combo [EventCodesCombo] always reverts to the 1st item which ever is selected.
Any ideas ?
Thank you
-- Wayne Manchester, England.
|
|
| |
| | | Wayne-I-M |  |
| Posted: Wed Sep 24, 2008 4:03 am Post subject: Re: Combo selection always the 1st ? |  |
| |  | |
6:55am (been here for an hour - after leaving at 10pm last night)
Just worked it out. OMG one of the questions that other posters tend to ask in thier 1st month of using access ??
I got the column widths wrong so the bound column was always the ID - in the AfterUpdate of a combo that filters the combo reverting to the 1st item. Of course this will always revert to the 1st if all the ID are the same on the filtering combo.
Doh.
What an idiot I am
Thanks for your answer - great as always
-- Wayne Manchester, England.
"Klatuu" wrote:
| Quote: | If I understand your question, Wayne, you are explicitly assigning the first value in the combo regardless of what is actually selected: cboEvent = EventCodesCombo.ItemData(0) The ItemData property returns the value of the bound column in the list. It is much like a collection or an array. ItemData(0) will always return the first row.
I think all you really need is:
cboEvent = EventCodesCombo
"Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message news:14A122A4-4F70-41D5-9E80-3AECB46A27D1@microsoft.com... Hi
I have an unbound combo [EventCodesCombo] that displayes a filter list of items.
SELECT [qryEventSorter].[EVTCode] FROM [qryEventSorter];
After update this combo sets the value of another combo
cboEvent = EventCodesCombo.ItemData(0)
The combo [EventCodesCombo] always reverts to the 1st item which ever is selected.
Any ideas ?
Thank you
-- Wayne Manchester, England.
|
|
| |
|
|