Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2007
    Posts
    93

    Unanswered: select listbox value from access vba

    hello freinds !!
    i have created a listbox which populates 7 choices
    i need to make a single selection out of 7 choices.

    now when ever user makes the selection out of any of the choices then on a button click the few functions would be called like

    begin:

    if choice 1
    then call function1
    else if choice 2
    then call function 2
    else if choice3
    then function3
    ....
    ....
    ...
    end

    i am looking out for some vba code... i am new to vba and i am just blank

    any thoughts would be appreciated
    thanks

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Select Case choice
        Case 1
            MsgBox "1"
        Case 2
            MsgBox "2"
        Case Else
            MsgBox "3"
    End Select
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2007
    Posts
    93

    select value from listbox

    thanks for the reply
    but i was looking out for the vba code which would be able to read the values
    like
    if listboxitemselected = 'A' then
    cal function1
    if listboxitemselected = 'b' then
    cal function2

    i have the concept bt unable to write the vba code for selcted values from listbox


    i would be glad if any of u guys help me with the code

    thanks

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Select Case Me.myListBox.Value
     ...
    George
    Home | Blog

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Just to elaborate a little:

    Code:
    Select Case Me.ListBoxName.Value
      Case 'A'
        SubroutineName1() ' or any other commands
      Case 'B'
        SubroutineName2() ' or any other commands
      etc
    End Select
    or you could use an IF statement like the following, but it's a little more inefficient:

    Code:
    If Me.ListBoxName = 'A' Then
      SubroutineName1() ' or any other commands
    ElseIf Me.ListBoxName = 'B' Then
      SubroutineName2() ' or any other commands
    ElseIf Me.ListBoxName = 'C' Then
      SubroutineName3() ' or any other commands
    End If
    Hope that's helpful.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Nov 2007
    Posts
    93

    select listbox

    thanks for the reply

    it worked fine ...
    appreciate ur help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •