Results 1 to 3 of 3
  1. #1
    Enrightt is offline Novice
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    10

    VBA How To Reference Active/Selected Field?

    I have a form that contains ~8 different date fields and I want to add a button that will update the currently selected field to today's date.



    I don't want to have 8 different buttons.

    Is there an Access form equivalent to reference selected field similar to Excel's .ActiveCell?

    Thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Research Screen.ActiveControl

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    one thing to be aware of is if you click a button to run some code screen.activecontrol will be the button. So also investigate screen.previouscontrol - and be aware with this if the user has previously clicked on a none date control, or no control at all, your code will fail so will need error handling to manage the failure.

    however, why click a button, why not use the control's doubleclick or mouseup (where right button is down) event? Benefit of the latter is if user clicks down, realises they have made a mistake, they can move the mouse off the control before releasing the button, so preventing the mouseup event firing.

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

Similar Threads

  1. Update a field with the active table name
    By rockell333 in forum Queries
    Replies: 8
    Last Post: 09-18-2015, 01:46 PM
  2. Yes/No Field, when active print text in a report
    By crobaseball in forum Access
    Replies: 2
    Last Post: 04-09-2014, 11:08 PM
  3. Replies: 21
    Last Post: 01-21-2014, 05:04 PM
  4. Replies: 1
    Last Post: 01-11-2014, 12:39 PM
  5. Replies: 11
    Last Post: 11-28-2012, 05:20 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