Results 1 to 5 of 5
  1. #1
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154

    How to access a combo box in Access VBA

    I have a main form called "Form1"


    Inside this form I have a command box called "x".
    When you click on "x", it shows another form called "Form2"
    Inside "Form2" there is a combo box called "y".

    I am trying to get to "y" from "Form1" inside access vba.


    I tried doing this but its not working

    Code:
    Me.Controls("x").Forms("Form2").Controls("y")
    Please can someone help me?

    Thank You

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Bookmark this page http://access.mvps.org/access/forms/frm0031.htm and keep looking at it occasionally for the next decade....

    Or use the expression builder to build the references for you.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154
    Thanks Minty for your input

    I looked at the link you sent me and in my particular case, I believed I should be at the area highlighted in yellow:

    Click image for larger version. 

Name:	Capture.jpg 
Views:	7 
Size:	252.2 KB 
ID:	37767

    so I wrote this vba code:

    Code:
    Me!x.Form!y
    but still no luck unless I am doing something wrong?

  4. #4
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Nope not right. From your description you aren't on the main form. You have opened a seperate form.

    From that page you need the reference for Not In These Forms - Forms!Mainform!ControlName
    Forms!Mainform!ControlName
    Forms!Mainform!ControlName
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    You have opened a seperate form.
    Maybe. Depends on what it "shows" means. Implies makes visible to me, not opens.
    Use of common Access jargon would help.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Access Form Combo Box
    By ZandyRox in forum Access
    Replies: 22
    Last Post: 07-16-2014, 10:30 AM
  2. Replies: 1
    Last Post: 10-30-2012, 10:29 AM
  3. Replies: 1
    Last Post: 07-11-2012, 08:36 AM
  4. Access 2003: Many to many combo box
    By compooper in forum Forms
    Replies: 1
    Last Post: 06-17-2011, 04:07 PM
  5. Access Combo Box Refresh
    By gafoor in forum Forms
    Replies: 1
    Last Post: 03-04-2011, 04:00 AM

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