Run-time error '35788'

jshutlz

New Member
Joined
Mar 10, 2010
Messages
12
I have a userform with 2 tabs - on the 2nd tab there are two fields that contain dates (using the Windows Date and Time Picker Control). I get this error when the first tab is selected and my userform updates with the data in my spreadsheet. It works just fine if the second tab is the tab on top. The complete error is:

Run-time error '35788' An error occured in a call to the Windows Date and Time Picker control

Here is the code I'm using

Code:
Private Sub Search_Click()
Dim r As Long
Dim ws As Worksheet
Set ws = Worksheets("Database")
LastRow = ws.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(0, 0).Row
If IsNumeric(RowNumber.Text) Then
    r = CLng(RowNumber.Text)
 
Else
 
    MsgBox "You must enter a number"
    Exit Sub
 
End If
If r > 1 And r <= LastRow Then
        txtHTName.Value = ws.Cells(r, 1)
        DTPicker1.Value = ws.Cells(r, 2)
        txtName.Value = ws.Cells(r, 3)
        txtTitle.Value = ws.Cells(r, 4)
        txtPhone.Value = ws.Cells(r, 5)
        txtFax.Value = ws.Cells(r, 6)
        txtEmail.Value = ws.Cells(r, 7)
        txtCompanyName.Value = ws.Cells(r, 8)
        txtParent.Value = ws.Cells(r, 9)
        txtAddress.Value = ws.Cells(r, 10)
        txtCity.Value = ws.Cells(r, 11)
        txtState.Value = ws.Cells(r, 12)
        txtWeb.Value = ws.Cells(r, 13)
        txtIndustry.Value = ws.Cells(r, 14)
        txtRev.Value = ws.Cells(r, 15)
        txtEmployee.Value = ws.Cells(r, 16)
        txtSource.Value = ws.Cells(r, 17)
        txtSourceName.Value = ws.Cells(r, 18)
        txtRecentActivity.Value = ws.Cells(r, 19)
        DTPicker2.Value = ws.Cells(r, 20)
        txtNextActivity.Value = ws.Cells(r, 21)
        DTPicker3.Value = ws.Cells(r, 22)
        txtTarget.Value = ws.Cells(r, 23)
        txtTargetFee.Value = ws.Cells(r, 24)
        txtTarget2.Value = ws.Cells(r, 25)
        txtTargetFee2.Value = ws.Cells(r, 26)
        txtProvider.Value = ws.Cells(r, 27)
        txtProb.Value = ws.Cells(r, 28)
        txtGeneral.Value = ws.Cells(r, 29)
 
 
ElseIf r = 1 Then
    MsgBox "No record available; please enter another number"
Else
 
    MsgBox "No record available; please enter another number"
 
End If
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Maybe you have two datetime pickers and you have to reference them separately? Not sure with two tabs what this means ...

Or possibly one of them is by default the "active" one.
 
Upvote 0
By tabs I mean that I added the "MultiPage" function to the form and the 2nd page has the dates. I actually have 3 datetime pickers (2 on the 2nd page and one that is not included on either page - this one doesn't give me any trouble). When the code I posted above runs, it runs just fine as long as the page that is selected is the one with the datetime pickers; however, if the other page is selected i get the above error.

Any solution?
 
Upvote 0
It seems its something about accessing the date picker when its not on an active tab (I may be fudging on the terminology here).

Without knowing more about date pickers (in fact, I know hardly anything at all), I'd suggest that you capture the dates at the time of entry. I.e., as soon as your user has selected a date, place it in a variable with form or project scope. If there is a default date (such as today), then initialize those variables with the same default data.

That way, you don't need to access the datepickers - just ask for the variable values that you have saved from them.

On userforms and variables:
http://www.dailydoseofexcel.com/archives/2004/07/22/passing-arguments-to-a-userform/
http://peltiertech.com/Excel/PropertyProcedures.html
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top