I'm not sure you understood the concept behind the code I posted in my
response. You do not need to have the DatePicker control visibly visible in
order to set it. Here is what I had posted (minus the variable
declaration)...
With Me.MultiPage1
CurrentPage = .Value
.Value = 1 ' This is tab number (zero based) containing the DatePicker
DTPickerReviewDate.Value = Date
.Value = CurrentPage
End With
Let's say that Tab #0 (default name Page1) is visible... the first line of
code stores this in the CurrentPage variable. Now, even though the second
line of code changes the Value property to 1, which makes Tab #1 (default
name Page2) visible,
VB will not show you that until the subroutine finishes
running... however, BEFORE the subroutine finishes, the code sets the Value
property back to the originally visible tab. The net result of this is the
display does NOT visibly change to the user... he/she sees a static looking
UserForm during the execution of the above code; but for the code's
purposes, the tab was made "visible" long enough so that the DatePicker's
value could be changed. Now, I see from your code that you have (at least)
two MultiPage controls. Believe it or not, the above trick can be played
with the visibility of the MultiPage control (housing the two DatePicker
controls) as well... you do not have to test the visibility as your posted
code does.
Okay, now to your code. You do not have to iterate each control on the
UserForm looking for your two DatePicker controls... you can address them
directly. Also, using the above discussion, you do not have to test for
visibility either. Okay, let's see if we can implement all of this and apply
it to your code. I believe you can *replace* the entire For..Next block of
code that you posted with this code (declare the CurrentPage variable as
Long and the MPVisibleState variable as Boolean)...
frm.MultiPage1.Value = 3
With frm.MultiPage2
MPVisibleState = .Visible
.Visible = True
CurrentPage = .Value
.Value = 0
DTPickerDate.Value = Cells(53, col).Value
.Value = 1
DTPickerTestDate.Value = Cells(61, col).Value
.Value = CurrentPage
.Visible = MPVisibleState
End With
I believe this code will run that same as what you posted and that the user
should not see any of the visibility manipulations that are taking place.
--
Rick (MVP - Excel)
"Shawn" wrote in message
...
Thank you very much for your help! I was able to use what you all gave me
to
finally get an answer. I failed to mention was that it was a DTPicker in a
multipage in a multipage ;( - hence nothing worked like it should have.
So using what you all had said I got it to work with this
Dim ctrl As msforms.Control
Dim col As Integer ' this is set elsewhere
Dim dDate As String
For Each ctrl In .Controls
If TypeName(ctrl) = "DTPicker" Then
With ctrl
Select Case (ctrl.Name)
Case ("DTPickerDate")
dDate = Cells(53, col).Value
frm.MultiPage1.Value = 3
frm.MultiPage2.Value = 0
If frm.MultiPage2.Pages("Page1").Visible = True
Then
.Value = dDate
End If
Case ("DTPickerTestDate")
dDate = Cells(61, col).Value
frm.MultiPage1.Value = 3
frm.MultiPage2.Value = 1
If frm.MultiPage2.Pages("Page2").Visible = True
Then
.Value = dDate
End If
Case Else
End Select
End With
End If
Next
End With
Thank you again - maybe this will help someone else aswell.
"Shawn" wrote:
Sorry needed to correct first post
How do I access a Date picker on a Multipage?
I want to assign it a value.
I have tried
frmTMF.MultiPage1.DTPickerReviewDate.Value = Date
and
frmTMF.DTPickerReviewDate.Value = Date
first returns error 438 - Object doesn't support this property or method
second returns error 35788 - An error occured in a call to the windows
date
and time picker control