A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Programmatically change combo box sorting



 
 
Thread Tools Display Modes
  #1  
Old November 4th, 2009, 10:08 PM posted to microsoft.public.access.forms
alt.binaries.cd.genealogy
external usenet poster
 
Posts: 2
Default Programmatically change combo box sorting

I am looking for a way in Acc2003 to change the sorting of a combo
box, depending if the user holds down the Shift key when clicking the
combo box (i.e. no shift key = sort order (A), shift key down = sort
order (B)).

I have tried changing the combo boxes .RowSource in the On Mouse Down
event (which works) and checking for the Shift key, but this somehow
prevents setting the selected item in the dropdown list. Actually
just setting the existing .RowSource in the On Mouse Down prevents
item selection in the dropdown list.

Any ideas ??
  #2  
Old November 5th, 2009, 01:03 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Programmatically change combo box sorting

Hi,
you can trap for use of shift key in the key down event. To use the key down
event, you must set the form's Key Preview to Yes.

Here's some sample code ( not for the arrow keys).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyD And ((Shift And acCtrlMask) 0) Then
MsgBox "Ctrl+D pressed."
End If
End Sub



vbKeyLeft LEFT ARROW key
vbKeyRight RIGHT ARROW key


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



"alt.binaries.cd.genealogy" wrote in message
...
I am looking for a way in Acc2003 to change the sorting of a combo
box, depending if the user holds down the Shift key when clicking the
combo box (i.e. no shift key = sort order (A), shift key down = sort
order (B)).

I have tried changing the combo boxes .RowSource in the On Mouse Down
event (which works) and checking for the Shift key, but this somehow
prevents setting the selected item in the dropdown list. Actually
just setting the existing .RowSource in the On Mouse Down prevents
item selection in the dropdown list.

Any ideas ??



  #3  
Old November 5th, 2009, 03:45 PM posted to microsoft.public.access.forms
Dorian
external usenet poster
 
Posts: 542
Default Programmatically change combo box sorting

Why not have them click the combo box label to change the sort order? You
could even change the label background color to reflect the order.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"alt.binaries.cd.genealogy" wrote:

I am looking for a way in Acc2003 to change the sorting of a combo
box, depending if the user holds down the Shift key when clicking the
combo box (i.e. no shift key = sort order (A), shift key down = sort
order (B)).

I have tried changing the combo boxes .RowSource in the On Mouse Down
event (which works) and checking for the Shift key, but this somehow
prevents setting the selected item in the dropdown list. Actually
just setting the existing .RowSource in the On Mouse Down prevents
item selection in the dropdown list.

Any ideas ??
.

  #4  
Old November 5th, 2009, 05:03 PM posted to microsoft.public.access.forms
alt.binaries.cd.genealogy
external usenet poster
 
Posts: 2
Default Programmatically change combo box sorting

On Nov 4, 7:03*pm, "Jeanette Cunningham"
wrote:
Hi,
you can trap for use of shift key in the key down event. To use the key down
event, you must set the form's Key Preview to Yes.

Here's some sample code ( not for the arrow keys).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
* * If KeyCode = vbKeyD And ((Shift And acCtrlMask) 0) Then
* * * * MsgBox "Ctrl+D pressed."
* * End If
End Sub

vbKeyLeft *LEFT ARROW key
vbKeyRight *RIGHT ARROW key

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



Jeanette,

Thanks for the help with the Key_Down code. Mostly I have a problem
when setting the .RowSource in the the Key_Down event, the combo box
stops working correctly.
  #5  
Old November 6th, 2009, 04:00 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Programmatically change combo box sorting

Mmm, there may well be an issue with changing the combo row source in the
key down event.
Like Dorian, I have always provided a button or label to change the sort
order of a combo.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



"alt.binaries.cd.genealogy" wrote in message
...
On Nov 4, 7:03 pm, "Jeanette Cunningham"
wrote:
Hi,
you can trap for use of shift key in the key down event. To use the key
down
event, you must set the form's Key Preview to Yes.

Here's some sample code ( not for the arrow keys).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyD And ((Shift And acCtrlMask) 0) Then
MsgBox "Ctrl+D pressed."
End If
End Sub

vbKeyLeft LEFT ARROW key
vbKeyRight RIGHT ARROW key

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



Jeanette,

Thanks for the help with the Key_Down code. Mostly I have a problem
when setting the .RowSource in the the Key_Down event, the combo box
stops working correctly.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.