Connecting Tech Pros Worldwide Forums | Help | Site Map

Set Value of ComboBox in VBA

Newbie
 
Join Date: Nov 2008
Posts: 26
#1: Jan 7 '09
Hi all,

I have combo box where I can choose week number (but it show also start and end date(call week number)) and also have end date(called edate) combo box .

Now i want to something, when i will choose week number, end date will be show up in edate combo box.

Example: when i select "1" in week number combo box, otherbox (edate) will show 2009/01/04

is it possible?

Thank you.
Attached Thumbnails
attachment1.bmp   attachment2.jpg  

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,747
#2: Jan 8 '09

re: Set Value of ComboBox in VBA


To set the value of the ComboBox in VBA simply assign the required value to it :
Expand|Select|Wrap|Line Numbers
  1. Me.EDate = #4 Jan 2009#
As far as accessing the non-default value of a ComboBox is concerned, you can use the Column property (Don't specify Row parameter if you want to use the default (selected) row) :
Expand|Select|Wrap|Line Numbers
  1. Me.EDate = Me.[Week Number].Column(2)
NB. From your pictures, column 2 (3rd column) is not actually a date value, but a date/time value. This is likely to cause you problems unless you're careful.

PS. Please remember in future to provide a meaningful name for your question (See FAQ - Thread titles).
Reply