John,
The For Each block in the AfterUpdate wasn't being executed when I would select a new value for the combo box by clicking the down arrow and clicking on another value in the list. Since a combo box does not have a muliselect capability, the value of the selected list item should also be combo box's value. Also, checking the Count property of the ItemSelected collection after selecting an item in the list returned zero.
Darrell
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of John Viescas
Sent: Wednesday, November 06, 2013 1:24 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Select First Item In Combo Box List By Default
Darrell-
Setting the value of the combo box doesn't necessarily make it "selected". You could have set the value AND the ItemsSelected, and then your original filter code would have worked.
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Embrey, Darrell
Sent: Wednesday, November 06, 2013 7:03 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Select First Item In Combo Box List By Default
Well then the collection never gets populated. I had the following in the AfterUpdate event for the combo box:
Private Sub cboRunSearch_AfterUpdate()
Dim varitem As Variant
For Each varitem In Me.cboRunSearch.ItemsSelected
Me.FilterOn = False
Me.Filter = "SessionID = " & Me.cboRunSearch.ItemData(varitem)
Me.FilterOn = True
Next
End Sub
When I would change the value of the combo box, the form's filter never changed. Stepping through the code, the For Each block never executed. When I checked the Count property for the ItemsSelected collection in the Immediate window it returned 0.
?me.cboRunSearch.itemsSelected.count
0
I wound up changing the AfterUpdate event to read:
Me.Filter = "SessionID = " & Me.cboRunSearch.ItemData(0)
Everything appears to working the way I wanted it to in the first place.
Darrell
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of John Viescas
Sent: Wednesday, November 06, 2013 12:47 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Select First Item In Combo Box List By Default
Yes, there is. But that's not the same as setting the Value of the combo to the first row.
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Embrey, Darrell
Sent: Wednesday, November 06, 2013 6:36 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Select First Item In Combo Box List By Default
So then despite what the help says, there isn't an ItemsSelected collection for a combo box.
Darrell
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Bob Khym
Sent: Wednesday, November 06, 2013 11:35 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Select First Item In Combo Box List By Default
try Me.cboRunSearch = item you want heighlighted. If the item you want highlighted is not the bound column, then set the bound value of the item you want selected.
i.e. bound item
1 dog
2 cat
3 horse
Me.cboRunSearch = 2 and cat will be heighlighted.
You can also use default value and set focus on cbo for heighlight
On Wednesday, November 6, 2013 10:26 AM, "Embrey, Darrell" <DEmbrey@bcbsm.com> wrote:
Greetings All,
I am working with Access 2007. I have a form that has a combo box in the header section to filter the data displayed in the form's detail section. I want to set the combo box's value to display the first item in the combo box's list. According to the help for the Selected property, I should be able to selected the first item in the list using the following in the form's Load event:
Me.cboRunSearch.Selected(0) = True
Obviously, this is not working or I wouldn't be writing this. What am I missing?
Darrell
Switch to: Text-Only, Daily Digest • Unsubscribe • Terms of Use • Send us Feedback
.
The information contained in this communication is highly confidential and is intended solely for the use of the individual(s) to whom this communication is directed. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information is prohibited. Please notify the sender, by electronic mail or telephone, of any unintended receipt and delete the original message without making any copies.
Blue Cross Blue Shield of Michigan and Blue Care Network of Michigan are nonprofit corporations and independent licensees of the Blue Cross and Blue Shield Association.
The information contained in this communication is highly confidential and is intended solely for the use of the individual(s) to whom this communication is directed. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information is prohibited. Please notify the sender, by electronic mail or telephone, of any unintended receipt and delete the original message without making any copies.
Blue Cross Blue Shield of Michigan and Blue Care Network of Michigan are nonprofit corporations and independent licensees of the Blue Cross and Blue Shield Association.
| Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (9) |
Tidak ada komentar:
Posting Komentar