PC Review


Reply
Thread Tools Rate Thread

How to change January 2008 to 1/1/2008

 
 
Chuck M
Guest
Posts: n/a
 
      27th Aug 2008
Hi - I'm a bit of a VBA novice. I need to take the result of a combobox
selection of month and year and convert it to mm/dd/yyyy format where dd is
always the first day of the month. Can anyone help?
--
TIA
Chuck M.
 
Reply With Quote
 
 
 
 
Stuart McCall
Guest
Posts: n/a
 
      27th Aug 2008
"Chuck M" <(E-Mail Removed)> wrote in message
news:8BD19653-F3BD-4AB5-9EBD-(E-Mail Removed)...
> Hi - I'm a bit of a VBA novice. I need to take the result of a combobox
> selection of month and year and convert it to mm/dd/yyyy format where dd
> is
> always the first day of the month. Can anyone help?
> --
> TIA
> Chuck M.


Dim selDate As Date

selDate = Cdate(Me.MonthCombo.Value & _
"/01/" & _
Me.YearCombo.Value)

The above code assumes that it is located in the form's module.


 
Reply With Quote
 
Chuck M
Guest
Posts: n/a
 
      27th Aug 2008
Stuart - Thanks for the quick reply. I did some additional research after my
original post and found this solution:

a = Me.cboCycleToBill
dt = Format(a, "mm/dd/yyyy")

This seems to give me the desired result. Do you see anything improper about
this solution? I am using dt in a where clause.
--
Thanks!
Chuck M.


"Chuck M" wrote:

> Hi - I'm a bit of a VBA novice. I need to take the result of a combobox
> selection of month and year and convert it to mm/dd/yyyy format where dd is
> always the first day of the month. Can anyone help?
> --
> TIA
> Chuck M.

 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      27th Aug 2008
If your combobox value is something like "January 2008", you can use CDate
which will convert that string to a date value of 1/1/2008.

CDate(Forms![NameofForm]!cboCycleToBill)

If you need that as a string in the format mm/dd/yyyy you can then apply the
format to the string.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

Chuck M wrote:
> Stuart - Thanks for the quick reply. I did some additional research after my
> original post and found this solution:
>
> a = Me.cboCycleToBill
> dt = Format(a, "mm/dd/yyyy")
>
> This seems to give me the desired result. Do you see anything improper about
> this solution? I am using dt in a where clause.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 200801 to January 2008 James Microsoft Access 2 4th Mar 2008 11:35 PM
8th January 2008 Ian News Editions 0 8th Jan 2008 06:12 PM
4th January 2008 Becky News Editions 2 7th Jan 2008 05:22 PM
2008 new year,2008 new business, 2008 new life, much cheap and beautiful product will help you which r u like ? yhnetstore5@gmail.com Microsoft C# .NET 0 5th Jan 2008 07:18 PM
FREE DOWNLOAD 2008's SOFTWARE: XSTEEL 13,AUTOCAD 2008,AUTODESK VIZ 2008,ANSYS 11! CD-SOFT2007 Microsoft ASP .NET 0 18th Jul 2007 05:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:21 AM.