date issue
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
date issue
Hi ,
In my userform, I have two date picker. First datepicker will show the log in date and second datepicker which is DTPicker2 should show the first date picker value + 8 days.
I am using the below formula in the second date picker but it seems it does not work. Any idea?
Thanks :)
Me.DTPicker2.Value = "Me.DTPicker1.Value + 8 days"
In my userform, I have two date picker. First datepicker will show the log in date and second datepicker which is DTPicker2 should show the first date picker value + 8 days.
I am using the below formula in the second date picker but it seems it does not work. Any idea?
Thanks :)
Me.DTPicker2.Value = "Me.DTPicker1.Value + 8 days"
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: date issue
Try this: (untested)
Me.DTPicker2.Value = DATEVALUE(Me.DTPicker1.Value) + 8 " days"
Me.DTPicker2.Value = DATEVALUE(Me.DTPicker1.Value) + 8 " days"
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Hi Rudi,
Thanks for your reply. Nope... its not working :(
thanks
Thanks for your reply. Nope... its not working :(
thanks
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: date issue
Try this instead:
Me.DTPicker2.Value = Me.DTPicker1.Value + 8
or
Me.DTPicker2.Value = DateAdd("d", 8, Me.DTPicker1.Value)
Me.DTPicker2.Value = Me.DTPicker1.Value + 8
or
Me.DTPicker2.Value = DateAdd("d", 8, Me.DTPicker1.Value)
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: date issue
I forgot the ampersand...
Try either one...
Me.DTPicker2.Value = DATEVALUE(Me.DTPicker1.Value) + 8 & " days"
Me.DTPicker2.Value = DATESERIAL(YEAR(Me.DTPicker1.Value),MONTH(Me.DTPicker1.Value),DAY(Me.DTPicker1.Value) + 8) & " days"
Ahhh...of course...the DateAdd function. Good one Hans!
Try either one...
Me.DTPicker2.Value = DATEVALUE(Me.DTPicker1.Value) + 8 & " days"
Me.DTPicker2.Value = DATESERIAL(YEAR(Me.DTPicker1.Value),MONTH(Me.DTPicker1.Value),DAY(Me.DTPicker1.Value) + 8) & " days"
Ahhh...of course...the DateAdd function. Good one Hans!
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Thanks Hans,
Its working.
Thanks rudi :)
Its working.
Thanks rudi :)
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Hi Hans and Rudi,
Regarding this issue, my datepicker is working only in the list box.
Me.DTPicker2.Value = DateAdd("d", 8, Me.DTPicker1.Value)
but , when i double click the userform to edit any of the value it does not getting update unless i search via listbox.
I tried to add the below code in the DTPicker2 but it seems its not working. any idea?
Dim wsh As Worksheet
Dim r As Long
Set wsh = Worksheets("Sheet1")
r = Me.DTPicker1
If IsDate(Me.DTPicker1.Value) Then
Me.DTPicker2.Value = DateAdd("d", 2, Me.DTPicker1.Value)
End If
Thanks :)
Regarding this issue, my datepicker is working only in the list box.
Me.DTPicker2.Value = DateAdd("d", 8, Me.DTPicker1.Value)
but , when i double click the userform to edit any of the value it does not getting update unless i search via listbox.
I tried to add the below code in the DTPicker2 but it seems its not working. any idea?
Dim wsh As Worksheet
Dim r As Long
Set wsh = Worksheets("Sheet1")
r = Me.DTPicker1
If IsDate(Me.DTPicker1.Value) Then
Me.DTPicker2.Value = DateAdd("d", 2, Me.DTPicker1.Value)
End If
Thanks :)
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: date issue
I think you'll need to set the value of DTPicker2 in the UserForm_Initialize event procedure of the userform.
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Hi Hans,
Thanks for your reply. How do you do that please
thanks
Thanks for your reply. How do you do that please
thanks
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: date issue
I assume that you have a line in UserForm_Initialize to set the value of DTPicker1. Please post that line.
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Hi Hans,
no i did not add any thing in the userform_initialize
thanks
no i did not add any thing in the userform_initialize
thanks
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: date issue
I'll have to see the workbook - otherwise it's impossible for me to know what's happening.
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Hi Hans,
Private Sub UserForm_Initialize()
Me.DTPicker3.Value = DateAdd("d", 23, Me.Week1.Value)
End Sub
thanks :)
Private Sub UserForm_Initialize()
Me.DTPicker3.Value = DateAdd("d", 23, Me.Week1.Value)
End Sub
thanks :)
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: date issue
OK, that code sets the value of DTPicker3. But how does DTPicker1 get its value?
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Hi Hans,
DTPicker1 using the same concept
Private Sub UserForm_Initialize()
Me.DTPicker1.Value = DateAdd("d",12,Me.Week1.Value)
End sub
DTPicker1 using the same concept
Private Sub UserForm_Initialize()
Me.DTPicker1.Value = DateAdd("d",12,Me.Week1.Value)
End sub
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: date issue
Try this:
Me.DTPicker2.Value = DateAdd("d", 14, Me.Week1.Value)
Change the value 14 as needed.
Me.DTPicker2.Value = DateAdd("d", 14, Me.Week1.Value)
Change the value 14 as needed.
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Hi Hans,
Thanks for your reply. I tried that as well. Its not working.
Is my userform_initialize() is correct? or do i need to change it?
Me.DTPicker1.Value = DateAdd("d",12,Me.Week1.Value) is working fine in the listbox but it does not work if the listbox is not clicked.
thanks again
Thanks for your reply. I tried that as well. Its not working.
Is my userform_initialize() is correct? or do i need to change it?
Me.DTPicker1.Value = DateAdd("d",12,Me.Week1.Value) is working fine in the listbox but it does not work if the listbox is not clicked.
thanks again
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: date issue
I repeat: I'll have to see the workbook. I can't offer further help without that.
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 148
- Joined: 18 Jun 2015, 09:46
Re: date issue
Thanks a lot for your help. I will put the workbook after little modification.
Thanks :)
Thanks :)