A family of Microsoft word processing software products for creating web, email, and print documents.
Or use the correct formatting switch with DTPicker1.Value
Format(DTPicker1.Value, "MMMM dd, yyyy")
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I have a date picker (DTPicker1) on a user form. In the document I have a docvariable ("DateEnd").
The starting value of the date picker (in properties) is 10/12/2012
In the userform code this runs when command button is clicked:
ActiveDocument.Variables("DateEnd").Value = Format(DTPicker1.Value, "mmmm dd, yyyy")
ActiveDocument.Range.Fields.Update
The docvariable populates with December 31, 1899 no matter what date I put in the picker box.
If I run this code:
MsgBox ufrmMain.DTPicker1.Value
it returns: 12:00:00 AM
I have other docvariables that are text which populate correctly from text boxes.
If I don't have the format code and populate with the value it returns 12:00:00 AM
What am I doing wrong with the date picker - how do I get the date?
Thank you.
EDIT: The format of the date picker is set to short date.
EDIT - naturally I found the solution right after I posted. I need to add the format switch to my docvariable field: @ "MMMM dd, yyyy"
A family of Microsoft word processing software products for creating web, email, and print documents.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Or use the correct formatting switch with DTPicker1.Value
Format(DTPicker1.Value, "MMMM dd, yyyy")
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more