Date format problem on form

I

Ixtreme

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
 
B

Bob Phillips

Ixtreme said:
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)
 
I

Ixtreme

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top