Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 02-11-2013, 01:39 AM
runninggordo runninggordo is offline Windows 7 32bit Office 2007
Novice
 
Join Date: Feb 2013
Posts: 2
runninggordo is on a distinguished road
Default 2 date issues

Hi There,

I am sorry if i am repeating another post but i could not see one.
I have two date issues in a word VBA userform project.

I am using calendar control 12.0 and it retuns a date in form 9/2/13 i need it to be Sunday 9th Febuary 2013 please help.

secondly i have a textbox that populates info from a spreadsheet that works well the another text box that calcultes with the ADDDate function to add one year for example Texbox 1 = 30/6/2013 - textbox 2 = 30/06/2014 but the textbox2 return in a us date eg. 06/30/2014 i need it to be 30/06/2014 but the format i am using example below retrns a very strange date which is 11/02/13 this is the format code


Private Sub nfyee_Change()
Me.nfyee.Value = Format(Date, "dd/mm/yyyy")
End Sub

Thanks heaps.
Gordon
Reply With Quote
  #2  
Old 02-11-2013, 02:50 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 17,485
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Gordon,

For the first problem, try something based on:
Code:
Private Sub Calendar1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Text = Format(Calendar1.Value, "DDDD ") & Ordinal(Calendar1.Day) & Format(Calendar1.Value, " MMMM YYYY")
End Sub
 
Function Ordinal(Val As Integer) As String
Dim strOrd As String
If (Val Mod 100) < 11 Or (Val Mod 100) > 13 Then strOrd = Choose(Val Mod 10, "st", "nd", "rd") & ""
Ordinal = Val & IIf(strOrd = "", "th", strOrd)
End Function
As for the second problem, have you validated the date value that is being obtained from the workbook?
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 02-11-2013, 03:00 AM
runninggordo runninggordo is offline Windows 7 32bit Office 2007
Novice
 
Join Date: Feb 2013
Posts: 2
runninggordo is on a distinguished road
Default

thank you so much that first one work a treat.

Ok this is where i am a dummy. I have not validated that field but that one is fine it is when i want it to calculate + 1 year it goes all funny.
Reply With Quote
  #4  
Old 02-11-2013, 03:38 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 17,485
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Quote:
Originally Posted by runninggordo View Post
I have not validated that field but that one is fine it is when i want it to calculate + 1 year it goes all funny.
What does your TextBox that imports the date actually display? What is the code that populates it?
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make table cell active add date count date MelHerndon Word VBA 3 01-21-2013 04:23 PM
Meaning of current date vs status date when saving baselines ketanco Project 1 02-08-2012 02:20 PM
Issues with synchronization log causing send/receive issues WinSock64 Outlook 0 01-11-2011 11:29 AM
new appointment date always reverts back to today's date msills Outlook 0 08-24-2007 08:57 AM
Imported message date change to today's date promark Outlook 1 12-23-2005 07:21 AM


All times are GMT -7. The time now is 01:30 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft