Results 1 to 6 of 6
  1. #1
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79

    Return current value from a combobox

    I have an active form MenuF on the screen. The form has a combox cboCluster. Is it possible to check what value actually returning from the combobox? Becasue I have following criterion in a query:



    [forms]![MenuF]![cboCluster]

    and the query doesn't return what I ecpected. I believe I misinterpret what value actually coming from the combobox.

    In VBA Excel it's possible to use Debug.Print or a MsgBox. I don't know how to do that in Access.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try this in the VBA Immediate window:

    ?[forms]![MenuF]![cboCluster]

    it should be the value in the bound column.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Great. That worked fine.

    One sub question. If I select an item (Actually a text string) in the list to my combobox, typing "?[forms]![MenuF]![cboCluster]" returns always 1 independent what I have selected in list to the combobox. That is creating my error. I want to return the text string in the combox. Any idea how I can get that instead of number 1?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    [forms]![MenuF]![cboCluster].column(1)

    presuming you you want the second column.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Thank you!

    That helped me a lot. Now I could actually use .Column(0) and and change slghtly in the macro code to a commandbutton.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Return Records in Current Fiscal Year
    By BLFOSTER in forum Programming
    Replies: 5
    Last Post: 05-06-2016, 07:53 PM
  2. Return records with empty combobox value
    By vincentsp in forum Queries
    Replies: 2
    Last Post: 02-18-2015, 04:41 PM
  3. Replies: 1
    Last Post: 10-12-2013, 05:39 PM
  4. Replies: 6
    Last Post: 05-20-2013, 08:42 AM
  5. Replies: 4
    Last Post: 11-10-2011, 03:16 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