Results 1 to 5 of 5
  1. #1
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200

    VBA to grab current subform field value

    Hi-



    I have a button on my subform that needs to grab the current value that ties my subform to the main form. For example, if the EmployeeID field ties the main form with the subform, but this field is not displayed on the subform, what do I have to code to get the EmployeID for the current record?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Me![EmployeID] should do it.

  3. #3
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Thanks. That worked. I wasn't aware that you could retrieve a value from a form even if it isn't on the form itself...it just has to be in the record source for the form. Correct?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Correct. It is why most developers use a different name for a bound control than the name of the field to which it is bound. Access can get confused when they are the same and you want "the other" one.

  5. #5
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Thanks much!

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

Similar Threads

  1. Grab first characters from field
    By sau3-access in forum Access
    Replies: 1
    Last Post: 10-04-2011, 10:40 AM
  2. export current view of subform
    By TheShabz in forum Programming
    Replies: 4
    Last Post: 07-19-2011, 05:32 PM
  3. Replies: 3
    Last Post: 05-07-2011, 10:25 AM
  4. Show only current record in report from form/subform
    By stelioshania in forum Reports
    Replies: 0
    Last Post: 03-02-2011, 02:19 PM
  5. Replies: 0
    Last Post: 05-09-2009, 09:04 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