Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box Highlight and Select Today's Date

Status
Not open for further replies.

crisis2007

Technical User
Apr 2, 2007
114
US
Hello -
Just looking for some help on a little problem. I have a listbox that is populated with dates. When the form containing the listbox is opened, I want the listbox to be defaulted to today's date. I sort of accomplished this by using the following in the Load Event of the form:

Me.List4.Value = Date

However this only highlights today's date. It would appear to the user that the date is actually selected when it is not and thus requiring the user to actually have to still click on it (unless they wish to choose another date in the list). I looked around and cannot find a solution to what seems to be a simple problem.
 
Why do you feel that it is only highlited and not selected

I tested this by createing a form with a listbox and a command button on form load
me.list0.value= date


on click of the command button

msgbox me.list0

and i get 12/13/11
 
As PWise said, the Listbox item has been selected. But if you're expecting some action to be carried out, based on this selection, such as code in the AfterUpdate event of List4, you'll have to explicitly call the AfterUpdate event. Populating a Control through code does not trigger Control-related events, such as AfterUpdate events.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks for responding PWise. As a result of your testing I looked a little further and realized I had code on the After Update Event of the listbox that triggers the value to populate a textbox on the form. This text box is what the report uses that is generated from a command button. So it is a design flaw on my part that is causing the problem. Thanks for your help! At least I now know where the problem is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top