I have two date boxes on a user form, txtDate and txt Due. Both have
check boxes that are default "false." I would like the txtDue to become
"true" when I check txtDate and automatically assume the same date as
txtDate. How do I accomplish this?
I have two date boxes on a user form, txtDate and txt Due. Both have
check boxes that are default "false." I would like the txtDue to become
"true" when I check txtDate and automatically assume the same date as
txtDate. How do I accomplish this?
Why not set the value property of the second box to try as part of the change method of the first.
Martin
Hi,
By coding your check box1 ...
Private Sub CheckBox1_Click()
CheckBox2.Enabled = True
CheckBox2.Value = CheckBox1.Value
End Sub
be sure to adjust with your names ...
HTH
Carim
Carim's method works, but it only enables txtDue when I click
txtDate. I actually want txtDue to stay disabled until I click it, I
just want it's value to change to the value in txtDate when I enable
it. (I dont always use a Due Date, but if I do it is generally the next
day or two, so it is easier to start from the Date.)(If that is clearer
than mud.)
I don't know how to follow mrice's advice. I tried to set the
value in txtDue to "txtDate" and get an error message. (???)
I appreciate your help.
if txtDate and txtDue are checkboxes and txtDue has the enabled property set
to false when the userform is shown. then you want to click one the area of
the disabled checkbox and have it come to life and take on the value of the
checkbox txtDate, then you can use this:
Private Sub UserForm_MouseDown(ByVal Button _
As Integer, ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
With txtDue
If Y >= .Top And Y <= .Top + .Height Then
If X >= .Left And X <= .Left + .Width Then
.Enabled = True
.Value = txtDate.Value
End If
Else
End If
End With
End Sub
--
Regards,
Tom Ogilvy
"L Scholes" wrote:
> Carim's method works, but it only enables txtDue when I click
> txtDate. I actually want txtDue to stay disabled until I click it, I
> just want it's value to change to the value in txtDate when I enable
> it. (I dont always use a Due Date, but if I do it is generally the next
> day or two, so it is easier to start from the Date.)(If that is clearer
> than mud.)
>
> I don't know how to follow mrice's advice. I tried to set the
> value in txtDue to "txtDate" and get an error message. (???)
>
> I appreciate your help.
>
>
I want both to be disabled when the userform is initally activated in
case I dont need the dates. I will have to enter a date, but not always
a due date, so I want them to activate independantly, but when I
activate txtDue, I want it to assume the same date as txtDate instead
of todays date. Not critical, but because the due date is always close
to the date it will be faster to start from the date instead of today.
I would try to use your method, but I'm not even sure where in my
current code to place it; I am trying now, after posting this.
This I think is what you're wanting. If not let me know.
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
CheckBox2.Value = True
textbox2.Value = textbox1.Value
Else:
CheckBox2.Value = False
textbox2.Value = Date
End If
End Sub
Adjust the names to your's and put the code under the checkbox that you're wanting to activate.
txtDate and txt due are both DTPickers and the "CheckBox" value is set
to "true" so there is a check box inside the box to activate the date,
i.e. no check box = no date, check box = date. I have the checkbox set
to be false by default so it won't print unless I ask it to, but I want
the default date to be the same as the date selected in txtDate when it
is activated. Your code has "checkbox1 & 2" but there are no separate
checkboxes.
I do appreciate your help!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks