Results 1 to 15 of 15
  1. #1
    khartoum is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    Liverpool
    Posts
    23

    Using access calendar to populate textbox

    Hi all,


    I have a calendar (calendar1) from which i want to populate a textbox (appt1) when i select the date on the calendar but im having problem with the code;
    i tried putting it against the on updated event of the calendar as below, but not sure how far off i am:
    Private Sub calendar1_Updated()
    Dim myDate As NewDate
    myDate = calendar1.SelectedDate
    appt1.Text = myDate
    End Sub

    Any help must appreciated

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    What is the problem you have? Are you getting an error?

    Is the Calendar Control bound to a Date field in a Table?

  3. #3
    khartoum is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    Liverpool
    Posts
    23
    I just added the calendar as an active X control, so it is not bound to anything
    is that the wrong way to do it?

    Anyhow message says 'Procedure declaration does not match description of event or procedure hving the same name; help says
    This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =[Field], this error occurs because Access expects a macro or event name to run when the event is fired.

    Hope this helps

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Try this instead [Note: I'm using the On Exit Event - not the On Update].
    It works once you tab off the Date Picker control [I'm assuming you used the Date Picker Active X control - right?

    Code:
    Private Sub DTPicker5_Exit(Cancel As Integer)
    
    Me.Text6 = Me.DTPicker5
    
    'Or . . . you can use this [just un-comment it]:
    'Me.Text6 = Format(Me.DTPicker5, "mm/dd/yyyy")
    
    End Sub
    Hope this helps!

  5. #5
    khartoum is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    Liverpool
    Posts
    23
    No, I only had the Calendar Control 12.0, not the date picker; do i need to download that for access 2007; is there no way i can use the standard calendar control

  6. #6
    khartoum is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    Liverpool
    Posts
    23
    Actually Robeen, it worked on the on Exit event, but ti would be more efficient if it just populated it when you chose date on calendar, many thanks though

  7. #7
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I agree - a straight forward Calendar control would be much better - however - Access 2010 doesn't come with a Calendar control - so I can't experiment with one easily.
    And I also agree that it would be a lot better if the code would fire as soon as a date is picked.
    I have never worked with Access 2007, though, and so I can't experiment with it here.
    What events are available for your Calendar Control? Have you tried putting the code in any of the other events?

  8. #8
    khartoum is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    Liverpool
    Posts
    23
    tried a couple but probably need to call a function or something along those lines, so will need the control - did you download the datepicker and does it trigger like we want it to

  9. #9
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    No - in Access 2010, you can open the Controls drop-down and there is an 'ActiveX Controls' option.
    When you click that a long list opens - and Microsoft Date & Time Picker Control 6.0 (SP4) is one of the available options.

    And No . . . it doesn't trigger like we wanted. I could not get the 'On Updated' Event to do anything . . . and I read on line that it just doesn't fire.

  10. #10
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Try using the on change event. I've used that successfully with the datepicker before.

  11. #11
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Quote Originally Posted by RayMilhon View Post
    Try using the on change event. I've used that successfully with the datepicker before.
    There isn't an On Change Event.
    Attached Thumbnails Attached Thumbnails DatePicker_Events.JPG  

  12. #12
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Must have confused it with the combo box my bad.

  13. #13
    khartoum is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    Liverpool
    Posts
    23
    Difficult to believe there is not a way to get this to populate the box using VBA, thnks for input

  14. #14
    khartoum is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    Liverpool
    Posts
    23
    All, I used link below and have now the calendar pop up, select date and Ok populates box - best i'll get for now
    thanks

  15. #15
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Figured out where I messed up in Access 2010 a Textbox will allow you to use a date field and acts very similar to a date picker but with all of the events of a text box. Access 2007 does not. I've been working with Access 2010 for over a year and forgot that Access 2007 does not have that.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-27-2012, 06:28 PM
  2. calendar on access
    By biagio in forum Access
    Replies: 1
    Last Post: 11-11-2011, 10:51 AM
  3. Unable to populate textbox based on listbox
    By marcustofeles in forum Forms
    Replies: 21
    Last Post: 10-24-2011, 07:18 AM
  4. Access Calendar Control
    By JGG in forum Access
    Replies: 7
    Last Post: 04-03-2009, 04:34 AM
  5. Access - Calendar Control
    By James890 in forum Forms
    Replies: 3
    Last Post: 04-01-2009, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums