+ Reply to Thread
Results 1 to 6 of 6

How to get date clicked on monthview to my textbox on userform?

Hybrid View

  1. #1
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Post How to get date clicked on monthview to my textbox on userform?

    I have a userform with a textbox for date. Besides this textbox, I have a small date icon that pops-up a calendar(MonthView1). When I click on a date in the monthview1 calendar, it does not get an entry into the textbox. I also tried using [Userform].[textbox].value= dateclicked logic, but it does not seem to work. Can anyone please take a look at it.

    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
    
    Txt_Prod_Loc_Date.Value = DateClicked
    
    Unload Me
    End Sub
    
    Private Sub FrmCalendar_Initialize()
    Unload Me
    End Sub
    Thanks,
    excelkann

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: How to get date clicked on monthview to my textbox on userform?

    Just a guess...

    Txt_Prod_Loc_Date.Value = MonthView1.Value
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: How to get date clicked on monthview to my textbox on userform?

    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
    
    Txt_Prod_Loc_Date.Value = DateClicked
    
    'Unload Me
    End Sub
    This syntax should work. Though I don't follow why you have the Unload Me in the procedure. That would close the userform when you select a date.
    Last edited by AlphaFrog; 04-11-2016 at 01:30 PM.

  4. #4
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: How to get date clicked on monthview to my textbox on userform?

    I tried both of these below
    Txt_Prod_Loc_Date.Value = DateClicked

    Txt_Prod_Loc_Date.Value = MonthView1.Value

    But I see a "Run-time error 424, object required". I am expecting the calendar to close, once date has been clicked. So, I am using unload me in my procedure. Am I missing anything more in the code?

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: How to get date clicked on monthview to my textbox on userform?

    I'm guessing you put the MonthView control on a second userform (hence the Unload Me command). Use comething like this to fully qualify the textbox on the 1st userform. Change the UserForm1 name to suit.

    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
    
    UserForm1.Txt_Prod_Loc_Date.Value = DateClicked
    
    Unload Me
    End Sub

  6. #6
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: How to get date clicked on monthview to my textbox on userform?

    Run time error 424 was happening because the program was not able to see the textbox present on a different User Form. So with

    Add_Inv.Txt_Prod_Loc_Date.Value = DateClicked
    the problem is solved. Add_Inv is my user form.

    Thanks very much @ AlphaFrog for your help. Greatly appreciate it.

    Regards,
    excelkann

+ 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. How to install date picker in UserForm: not seeing Monthview control in References
    By Pimp_mentality in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2015, 04:38 PM
  2. [SOLVED] Excel 2010 - Userform - display date from textbox in a label or textbox in 'ddd' format
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2015, 10:54 PM
  3. Populate data when monthview clicked on userform
    By imzhakmaya in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2014, 05:38 AM
  4. [SOLVED] Excel 2007, Userform Textbox Date Format and Calendar Control Userform
    By riffology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2014, 06:18 PM
  5. Show Monthview via Image Click in Userform
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2013, 11:55 AM
  6. [SOLVED] Date problem in monthview userform
    By h0ps in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2012, 12:10 PM
  7. Calender enters date into clicked on textbox
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-03-2008, 05:14 AM

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