+ Reply to Thread
Results 1 to 4 of 4

DatePicker (Eyre) selectdate causing Runtime error 13 if text box empty

  1. #1
    Registered User
    Join Date
    04-24-2020
    Location
    Sydney, Australia
    MS-Off Ver
    365
    Posts
    3

    DatePicker (Eyre) selectdate causing Runtime error 13 if text box empty

    Hello,
    I'm very new to VBA. I've searched datepicker threads and found no answer for my problem.

    I have several date fields in a user form, which for example DOB can be 80-90 years ago. The Eyre date picker is working fine in it's most basic form without options. If a user wants to change the date, the date picker is defaulting to the current month and year which for DOB is frustrating for users as you need to scroll through up to 90 years. The code below works fine if there is data in the text box ie datepicker starts at the date already in the text box, but when the text box is empty (new data entry) it causes a runtime error 13 (data type mismatch).


    Private Sub imgDateDeath_Click()
    Dim myDate As Date

    myDate = CalendarForm.GetDate '(SelectedDate:=txtDateDeath.Value)

    If myDate > 0 Then
    txtDateDeath.Value = Format(myDate, "dd/mm/yyyy")
    End If

    End Sub


    Any advice is gratefully received.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: DatePicker (Eyre) selectdate causing Runtime error 13 if text box empty

    What is Private Sub imgDateDeath_Click() if you are putting result in a textbox ???????
    If you are stuck attached another option - this has combo to take you back & forward - the range can be altered in the code.
    The demo fires on the double-click in columns A & B - you can alter the code to trigger in your textboxes.

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-24-2020
    Location
    Sydney, Australia
    MS-Off Ver
    365
    Posts
    3

    Re: DatePicker (Eyre) selectdate causing Runtime error 13 if text box empty

    Thanks.
    Here is a sample file.



    myDate = CalendarForm.GetDate(SelectedDate:=txtDateDeath.Value)

    works fine if you search for existing client with data, but not when form is reset and field is empty. I can't have default values because the people entering the data wont actually change it.

    Thanks again
    Attached Files Attached Files

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: DatePicker (Eyre) selectdate causing Runtime error 13 if text box empty

    I used the 'Eyre' calendar in an app submitted on this site some time back.
    I found i had to transfer to the main form the code element relevant to the calendar type.
    I only used the double click to call the calendar, you are using two call methods are they conflicting.
    Look through the attached app it may provide a guide as to the handling of the calendar.
    torachan.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Connect Userform Text or other to VBA Date Picker (of Trevor Eyre)
    By ProfXer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-09-2020, 04:11 PM
  2. [SOLVED] Runtime Error 13 - due to empty cell (no value)
    By Chaos00 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2018, 06:17 AM
  3. [SOLVED] Worksheet Change Event Causing Runtime Error 9
    By phelbin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2017, 03:59 PM
  4. PasteSpecial causing RunTime error 1004 & autofill doesn't stop at last line
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2014, 09:18 AM
  5. [SOLVED] Application.Calculate or F9 causing runtime / Visual Basic error
    By baldmosher in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2013, 05:26 AM
  6. Application.Calculate causing Runtime Error
    By quekbc in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-20-2013, 05:14 AM
  7. CSV empty file causing an error
    By scantron in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2012, 04:31 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1