Results 1 to 7 of 7
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Getting a value from another form

    I need to get a value from another form. I'm still working on learning VBA. Here's the error and my code.


    Click image for larger version. 

Name:	E1.jpg 
Views:	10 
Size:	20.0 KB 
ID:	33777

    Click image for larger version. 

Name:	E2.jpg 
Views:	10 
Size:	45.8 KB 
ID:	33778

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Try Forms!frmMainMenu.UserID
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Awesome! Thanks. Worked great. I put that extra "me." in it.

  4. #4
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I have one more like it. I have a value in a subform [frmWeaponsSubF] and want to populate the field [ReturnedByID] with the same information as the previous. Here's what I get.

    Click image for larger version. 

Name:	E3.jpg 
Views:	10 
Size:	13.3 KB 
ID:	33779

    Click image for larger version. 

Name:	E4.jpg 
Views:	10 
Size:	44.8 KB 
ID:	33780

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I just got it.
    Me.frmEquipReturnSubF!ReturnedByID.Value = Forms!frmMainMenu.txtUserID

    I'm learning

  6. #6
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    If its in a subform, you should use this:

    Code:
    Me.frmEquipReturnSubF.Form.ReturnedByID = Forms!frmMainMenu.txtUserID
    NOTE .Value isn't needed as it's the default for controls

    See this link for more info on referencing subform controls: http://allenbrowne.com/casu-04.html
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  7. #7
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    That worked perfectly. Thanks.

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

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