PC Review


Reply
Thread Tools Rate Thread

Date format problem on form

 
 
Ixtreme
Guest
Posts: n/a
 
      13th Aug 2007
I have a form on which a date can be entered in textbox1. After
clicking OK and submitting the form, the data is copied automatically
to a sheet.

The problem is that if a user wants to enter a date like 1 february
2007, the date in my sheet displays this date as if the user entered
2nd of january. What I would like to have is:

1. Preformat the textbox1 like DD/MM/YYYY. (If the form opens,
textbox1 should display DD/MM/YYYY. Upon selecting the cell, the user
can overwrite this with in this case: 01/02/2007
2. Display a label on the form displaying the long date of the date
the user has entered.
3. Display the correct date on my sheet as an integer (I use this
value to sort my list on)

PS: Everything independent of the users' local settings !!

Thanks,

Mark

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      13th Aug 2007

"Ixtreme" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a form on which a date can be entered in textbox1. After
> clicking OK and submitting the form, the data is copied automatically
> to a sheet.
>
> The problem is that if a user wants to enter a date like 1 february
> 2007, the date in my sheet displays this date as if the user entered
> 2nd of january. What I would like to have is:
>
> 1. Preformat the textbox1 like DD/MM/YYYY. (If the form opens,
> textbox1 should display DD/MM/YYYY. Upon selecting the cell, the user
> can overwrite this with in this case: 01/02/2007



When loading the textbox, use

TextBox1.Text = Format(Range("A1").Value, "dd/mm/yyyy")


> 2. Display a label on the form displaying the long date of the date
> the user has entered.
> 3. Display the correct date on my sheet as an integer (I use this
> value to sort my list on)



Range("B2").Value = CLng(TextBox1.Text)


 
Reply With Quote
 
Ixtreme
Guest
Posts: n/a
 
      13th Aug 2007
Bob,

I receive a type mismatch. Is there something I have overseen here?

Private Sub CommandButton1_Click()

.......
Range("D" & LastRow).Value = CLng(TextBox1.Text) '
TextBox1.Text = "13-08-2007" as expected

end sub

and I have:

Private Sub UserForm_Activate()
.......
TextBox1.Text = Format(Range("J2").Value, "dd/mm/
yyyy") 'In cell J2 I have =Today()
.......
End Sub

Thanks ,

Mark


 
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
Date format problem from form to sheet Steen Microsoft Excel Misc 6 23rd Oct 2008 06:56 AM
Open form code to enter a date in short date format =?Utf-8?B?VGFuZHk=?= Microsoft Access Form Coding 5 5th Jul 2005 07:05 PM
[Newbie UK Date problem] Ways atround this UK date format localisation/SQLselection issue? DC Microsoft C# .NET 5 1st Jul 2005 10:35 PM
Date Format Problem in Form Gina Microsoft Access Form Coding 1 10th Mar 2005 03:48 AM
form field date format with default date Keith G Hicks Microsoft Word Document Management 1 15th Oct 2004 10:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 PM.