Results 1 to 4 of 4
  1. #1
    VicM is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2017
    Location
    US-PA & FL
    Posts
    55

    datepicker oddity causing issues

    Hi,

    Using Access 2010 on Win7 Pro box.

    I have a form with a date field that has the 'Show Date Picker' property set to 'For dates'. That field also has the Set Focus property set on Form Open.
    The form also has a Close button with code that closes said form and opens another based on how said form was opened; whether from another form (based on OpenArgs) or directly from the Switchboard.

    The problem occurs if the user, once opening the form then decides to close it without entering any data, and therefore the focus not moving to any other control, clicks on the Close button. Because the focus is still set to the date field, clicking the Close button causes the calendar to appear in the date field and the code behind the Close button doesn't execute.

    I've tried coding to shift the focus away from the date field when the Close button is clicked or in the Close button's other events: OnGotFocus, OnMouseMove, OnMouseDown and OnEnter. But nothing works to pull the focus away from the date field.

    Obviously if the user enters any data into the form, the focus will be away from the date field and the Close button's code will function properly.

    How can I solve this issue? Or do I have to set the focus on another field when opening the form? (Not my preference.)

    Thanks,
    Vic

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What do you mean by SetFocus property? I don't find such property. Do you mean TabIndex property is 0?

    I cannot replicate issue. Post your code or provide db for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    VicM is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2017
    Location
    US-PA & FL
    Posts
    55
    In my Form.Open event I have the following line of code:

    Me.datFrom.SetFocus

    Where datFrom is the name of the date control.

    And coincidentally that control does have a Tab Index property of 0.

  4. #4
    VicM is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2017
    Location
    US-PA & FL
    Posts
    55
    The date control had the 'ShortDate' format property in it. When I removed that, the form's Close button executed properly.
    Go figure. This is not the first time another property in the control has caused an issue with some code.
    Anyway I'm marking this thread as solved.

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

Similar Threads

  1. Upgrade to Windows 10 causing issues with Graphs
    By brian11670 in forum Access
    Replies: 2
    Last Post: 08-19-2019, 01:18 PM
  2. Change from DAO to ADO causing issues
    By PinkLady50 in forum Programming
    Replies: 17
    Last Post: 05-15-2017, 03:13 PM
  3. Replies: 3
    Last Post: 04-06-2016, 10:28 AM
  4. Replies: 6
    Last Post: 04-28-2014, 06:48 AM
  5. Replies: 3
    Last Post: 04-20-2012, 01:30 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