Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 13th, 2004, 05:15 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default USER SELECTION FROM A COMBOBOX

Hello

Is there a way in VBA of setting a particular row in a combobox to display at the top of the list?

That is, we have a cbo that contains a list of training dates (this can be as much 80+ dates). The recordsource comes via VBA/SQL depending on a course type that is selected from another cbo.

At present when a user wishes to select a date there is a lot of scrolling to do before the desired date appears. The dates are in desc order so December dates appear at the top of the list. However, the user will normally wish to select a date within the current month or the next month.

So ideally at any time of the year the user would like to have the current month displayed at the top of the cbo list to afford quick selection.

Any help on this would be much appreciated.
 
Old February 14th, 2004, 12:46 AM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can set the default value to the date you want.

Me.Combo1.DefaultValue = Date()

or something close to that.



Sal
 
Old February 14th, 2004, 05:02 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi AxeSess,
I agree with Sal but, depending on which column is bound in your cbox & how it's formatted, will require a little more modification.
I understand the training dates are not incremented day by day, thus, Date() may not correspond with a particular traing day...your cbox will not function correctly...
If the trainingday cbobox is bound to a sql statement, then in the "order by " clause, make it equal current month.
eg Dim iMonth as integer
iMonth = Month(Date)
OrderBy [cboTraingDay] = "Like 'iMonth/*/*'"

..at least you get the idea. Syntax may be off slightly, but the concept should be valid.
Hope this helps, (obviously, I took a lot for granted).


 
Old February 15th, 2004, 06:48 AM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Sal and DBoulos

Sal reminded me that the simple solutions are often the best. DBoulos you are right on track in that the date is not the bound column in the cbo.

Have not done it yet (important football match to watch first) but I get the general idea of your suggestion and will attempt something along those lines.

Thanks to you both.

Murry






Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill DataGrid based on the selection in combobox drani C# 12 October 11th, 2007 05:41 PM
Changing combobox based on selection iamme Visual Basic 2005 Basics 0 January 31st, 2007 09:04 PM
How to catch mouse selection on a combobox? jeffcflam Pro VB 6 0 May 24th, 2006 07:22 AM
ComboBox Selection Question vtonny1 Access 2 February 11th, 2006 01:14 PM
Forms: Restrict user selection - How? cdplayer Classic ASP Basics 2 February 29th, 2004 03:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.