Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

List Box in MS Access

Discussion in 'Information Technology' started by Kent, Jul 28, 2006.

Tags:
  1. Kent

    Kent
    Expand Collapse
    Guest

    How can i get the value of selected item in the listbox using VBA??
     
  2. Loading...

    Similar Threads Forum Date
    Sikh News How The Left & Indian Nationalists Distorted The History Of Sikh Gadhar Movement - Breaking News Sep 21, 2016
    Interfaith Materialists And Its Discontents Interfaith Dialogues Jun 10, 2016
    Sikhi Quasi-Pragmatists And Quasi-Spiritualists, Care To Explain? Sikh Sikhi Sikhism Jun 6, 2016
    Cholesterol Is Finally Officially Removed From "naughty List" Health & Nutrition Feb 11, 2016
    Listening to Gurbani while driving?? Sikh Rehat Maryada Jan 13, 2016

  3. Nikos Yannacopoulos

    Nikos Yannacopoulos
    Expand Collapse
    Guest

    Kent,

    Just reference it, like any other control on a form:

    Me.MyListbox

    in the form's own module, or

    Forms!MyForm!MyListbox

    in any other form.

    HTH,
    Nikos
     
  4. Kent

    Kent
    Expand Collapse
    Guest

    thanks Nikos! :)


    "Nikos Yannacopoulos" wrote:

    > Kent,
    >
    > Just reference it, like any other control on a form:
    >
    > Me.MyListbox
    >
    > in the form's own module, or
    >
    > Forms!MyForm!MyListbox
    >
    > in any other form.
    >
    > HTH,
    > Nikos
    >
     
  5. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    doesn't work for multiselect listboxes

    Dim CurVal As Variant
    Dim lb As Access.Listbox
    Dim selVal As Variant

    set lb = Me.MyListBox

    For Each CurVal in Lb.ItemsSelected
    selVal=lb.ItemData(lb.ItemsSelected(CurVal))
    ' Do The stuff
    Next

    Pieter


    "Kent" <Kent@discussions.microsoft.com> wrote in message
    news:D6BD2CD6-5F95-42CB-9149-BBB505DFA81F@microsoft.com...
    > thanks Nikos! :)
    >
    >
    > "Nikos Yannacopoulos" wrote:
    >
    >> Kent,
    >>
    >> Just reference it, like any other control on a form:
    >>
    >> Me.MyListbox
    >>
    >> in the form's own module, or
    >>
    >> Forms!MyForm!MyListbox
    >>
    >> in any other form.
    >>
    >> HTH,
    >> Nikos
    >>
     
  6. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    doesn't work for multiselect listboxes

    Dim CurVal As Variant
    Dim lb As Access.Listbox
    Dim selVal As Variant

    set lb = Me.MyListBox

    For Each CurVal in Lb.ItemsSelected
    selVal=lb.ItemData(lb.ItemsSelected(CurVal))
    ' Do The stuff
    Next

    Pieter


    "Kent" <Kent@discussions.microsoft.com> wrote in message
    news:D6BD2CD6-5F95-42CB-9149-BBB505DFA81F@microsoft.com...
    > thanks Nikos! :)
    >
    >
    > "Nikos Yannacopoulos" wrote:
    >
    >> Kent,
    >>
    >> Just reference it, like any other control on a form:
    >>
    >> Me.MyListbox
    >>
    >> in the form's own module, or
    >>
    >> Forms!MyForm!MyListbox
    >>
    >> in any other form.
    >>
    >> HTH,
    >> Nikos
    >>




    --
    ----------------------------------------
    I am using the free version of SPAMfighter for private users.
    It has removed 4285 spam emails to date.
    Paying users do not have this message in their emails.
    Get the free SPAMfighter here: http://www.spamfighter.com/len
     
  7. Angus Comber

    Angus Comber
    Expand Collapse
    Guest

    I can't get your code to work. I have a multiselect listbox. I would also
    like to be able to properly select a row - ie when I click on a row it
    doesn't appear in reverse video - eg like if you select an email in Outlook
    Express.

    If I use your code I get no CurVal value - like I haven't selected anything.
    There is only one row of data in my listbox and one header row.

    Any ideas?

    Angus



    "Pieter Wijnen"
    <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
    ..with.norway> wrote in message news:#G$B$mKrGHA.3856@TK2MSFTNGP02.phx.gbl...
    > doesn't work for multiselect listboxes
    >
    > Dim CurVal As Variant
    > Dim lb As Access.Listbox
    > Dim selVal As Variant
    >
    > set lb = Me.MyListBox
    >
    > For Each CurVal in Lb.ItemsSelected
    > selVal=lb.ItemData(lb.ItemsSelected(CurVal))
    > ' Do The stuff
    > Next
    >
    > Pieter
    >
    >
    > "Kent" <Kent@discussions.microsoft.com> wrote in message
    > news:D6BD2CD6-5F95-42CB-9149-BBB505DFA81F@microsoft.com...
    > > thanks Nikos! :)
    > >
    > >
    > > "Nikos Yannacopoulos" wrote:
    > >
    > >> Kent,
    > >>
    > >> Just reference it, like any other control on a form:
    > >>
    > >> Me.MyListbox
    > >>
    > >> in the form's own module, or
    > >>
    > >> Forms!MyForm!MyListbox
    > >>
    > >> in any other form.
    > >>
    > >> HTH,
    > >> Nikos
    > >>

    >
    >
     
  8. Angus Comber

    Angus Comber
    Expand Collapse
    Guest

    I had ControlSource = then I put in name of table - seemed to screw
    everything up. Once I removed everything was fine.

    God I thought making the move from VB to Access would be easy!!!

    Angus


    "Angus Comber" <nospam@gmail.com> wrote in message
    news:OPxzaQLrGHA.716@TK2MSFTNGP03.phx.gbl...
    > I can't get your code to work. I have a multiselect listbox. I would

    also
    > like to be able to properly select a row - ie when I click on a row it
    > doesn't appear in reverse video - eg like if you select an email in

    Outlook
    > Express.
    >
    > If I use your code I get no CurVal value - like I haven't selected

    anything.
    > There is only one row of data in my listbox and one header row.
    >
    > Any ideas?
    >
    > Angus
    >
    >
    >
    > "Pieter Wijnen"
    >

    <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please@online.replace
    > .with.norway> wrote in message

    news:#G$B$mKrGHA.3856@TK2MSFTNGP02.phx.gbl...
    > > doesn't work for multiselect listboxes
    > >
    > > Dim CurVal As Variant
    > > Dim lb As Access.Listbox
    > > Dim selVal As Variant
    > >
    > > set lb = Me.MyListBox
    > >
    > > For Each CurVal in Lb.ItemsSelected
    > > selVal=lb.ItemData(lb.ItemsSelected(CurVal))
    > > ' Do The stuff
    > > Next
    > >
    > > Pieter
    > >
    > >
    > > "Kent" <Kent@discussions.microsoft.com> wrote in message
    > > news:D6BD2CD6-5F95-42CB-9149-BBB505DFA81F@microsoft.com...
    > > > thanks Nikos! :)
    > > >
    > > >
    > > > "Nikos Yannacopoulos" wrote:
    > > >
    > > >> Kent,
    > > >>
    > > >> Just reference it, like any other control on a form:
    > > >>
    > > >> Me.MyListbox
    > > >>
    > > >> in the form's own module, or
    > > >>
    > > >> Forms!MyForm!MyListbox
    > > >>
    > > >> in any other form.
    > > >>
    > > >> HTH,
    > > >> Nikos
    > > >>

    > >
    > >

    >
    >
     
  9. Nikos Yannacopoulos

    Nikos Yannacopoulos
    Expand Collapse
    Guest

    > God I thought making the move from VB to Access would be easy!!!

    Angus,

    The two are quite different, but once you familiarize more with Access
    you'll find it's much faster to develop apps with than VB.

    Nikos
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page