Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Userforms and Dates

I'm getting month and year values from a user form. The months are in the
form January, February, etc. and the years are 2004,2005, 2006. I want to
get the date from the entered values and I've used this equation

PlanDate = Date( Me.cboPlanYear.Value, me.cboPlanMonth.Value,1)

For some reason, it gives me a compile error on this statement. What am I
missing?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Userforms and Dates

Hi Barb

You must load the combobox with two columns
1 Jan
2 Feb

Hide the first column so you only see the month names
Then use Bound column to read the numbers and not the month name



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Barb Reinhardt" wrote in message
...
I'm getting month and year values from a user form. The months are in the
form January, February, etc. and the years are 2004,2005, 2006. I want to
get the date from the entered values and I've used this equation

PlanDate = Date( Me.cboPlanYear.Value, me.cboPlanMonth.Value,1)

For some reason, it gives me a compile error on this statement. What am I
missing?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Userforms and Dates

first, Date is what you would use in a worksheet,

DateSerial would be used in VBA.

But either one expects a number for month. for your values use

PlanDate = DateValue(me.cboPlanMonth.Value & " 1, " & Me.cboPlanYear.Value)


or for international considerations

PlanDate = cDate(me.cboPlanMonth.Value & " 1, " & Me.cboPlanYear.Value)
--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote:

I'm getting month and year values from a user form. The months are in the
form January, February, etc. and the years are 2004,2005, 2006. I want to
get the date from the entered values and I've used this equation

PlanDate = Date( Me.cboPlanYear.Value, me.cboPlanMonth.Value,1)

For some reason, it gives me a compile error on this statement. What am I
missing?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Userforms and Dates

Maybe easier to use the listindex it this case

Fill the combo with month names
and it your Dateserial use

me.cboPlanMonth.ListIndex + 1

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Ron de Bruin" wrote in message ...
Hi Barb

You must load the combobox with two columns
1 Jan
2 Feb

Hide the first column so you only see the month names
Then use Bound column to read the numbers and not the month name



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Barb Reinhardt" wrote in message
...
I'm getting month and year values from a user form. The months are in the
form January, February, etc. and the years are 2004,2005, 2006. I want to
get the date from the entered values and I've used this equation

PlanDate = Date( Me.cboPlanYear.Value, me.cboPlanMonth.Value,1)

For some reason, it gives me a compile error on this statement. What am I
missing?

Thanks





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need some help with userforms T.c.Goosen1977 Excel Discussion (Misc queries) 0 June 30th 06 09:27 AM
Userforms restrepoblessin Excel Programming 1 September 12th 05 04:26 PM
Userforms Paul Clark Excel Programming 2 January 17th 04 04:51 PM
dates in userforms Ben G Excel Programming 0 July 8th 03 04:55 PM
dates in userforms Ben Guenther Excel Programming 0 July 8th 03 03:44 PM


All times are GMT +1. The time now is 07:06 AM.

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

About Us

"It's about Microsoft Excel"