Add Items from a listbox to a table


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Add Items from a listbox to a table

  1. #1
    Dean Earley Guest

    Re: Add Items from a listbox to a table

    > Hi,
    > I want to add items from a list box to a table in Ms-Access.
    > I want to add the items altogether as oppossed to having the user clicking
    > on each item and adding them like that.
    >
    > How do I loop through a listbox. I have tried different things but none are
    > working.


    What have you tried?

    I wont give you code, but I will explain how to fix it )

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems



  2. #2
    Gill Guest

    Add Items from a listbox to a table


    Hi,
    I want to add items from a list box to a table in Ms-Access.
    I want to add the items altogether as oppossed to having the user clicking
    on each item and adding them like that.

    How do I loop through a listbox. I have tried different things but none are
    working.

    Any Help wouold be great!

    Thanks

    Gill

  3. #3
    Gill Guest

    Re: Add Items from a listbox to a table


    Hi Dean thanks for your reply.
    I have tried using looping and for next statements.
    I open my recordset and then I have teh following code

    Dim i
    For i = 1 To 100
    With rst
    .AddNew
    .Fields("name") = lstname.ItemData(i)
    .Fields("Id") = lstIDNo.ItemData(i)
    .Update
    End With
    Next i

    I know this doesn't work but I have tried other things and I just can't seem
    to get my head around it and I can't find any information on it!

    Thanks for any help




    "Dean Earley" <dean.earley@icode.co.uk> wrote:
    >> Hi,
    >> I want to add items from a list box to a table in Ms-Access.
    >> I want to add the items altogether as oppossed to having the user clicking
    >> on each item and adding them like that.
    >>
    >> How do I loop through a listbox. I have tried different things but none

    are
    >> working.

    >
    >What have you tried?
    >
    >I wont give you code, but I will explain how to fix it )
    >
    >--
    >Dean Earley (dean.earley@icode.co.uk)
    >Assistant Developer
    >
    >iCode Systems
    >
    >



  4. #4
    Dean Earley Guest

    Re: Add Items from a listbox to a table

    > Hi Dean thanks for your reply.
    > I have tried using looping and for next statements.
    > I open my recordset and then I have teh following code
    >
    > Dim i
    > For i = 1 To 100
    > With rst
    > AddNew
    > Fields("name") = lstname.ItemData(i)
    > Fields("Id") = lstIDNo.ItemData(i)
    > Update
    > End With
    > Next i
    >
    > I know this doesn't work but I have tried other things and I just can't seem
    > to get my head around it and I can't find any information on it!


    Which bit doesn't work?
    How many items in the listbox?
    ps, the first item is 0 and goes to listbox.listCount-1

    You may want to look at the List property instead of the ItemData Property (it defaults to 0 and can only contain a number)

    You will also need the . before every item that should be part of rst
    e.g.
    With rst
    ..AddNew
    ..Fields ....

    Hope this gets you going on the right track

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems






  5. #5
    gill Guest

    Re: Add Items from a listbox to a table


    That didn't work, I'm getting wrong argument for itemdata and for listcount!
    Can you show me an example so I can work from that? I just want to be able
    to loop through the list on the list box and add the items as we go.


    Dim i
    For i = 0 To 100
    With rst
    .AddNew
    .Fields("name") = lstname.ItemData(i)
    .Fields("Id") = lstIDNo.ItemData(i)
    .Update
    End With
    Next i

    any more help is appreicated, it has to be something simple that I am doing
    wrong!!!

    Thanks
    Gill

    "Dean Earley" <dean.earley@icode.co.uk> wrote:
    >> Hi Dean thanks for your reply.
    >> I have tried using looping and for next statements.
    >> I open my recordset and then I have teh following code
    >>
    >> Dim i
    >> For i = 1 To 100
    >> With rst
    >> AddNew
    >> Fields("name") = lstname.ItemData(i)
    >> Fields("Id") = lstIDNo.ItemData(i)
    >> Update
    >> End With
    >> Next i
    >>
    >> I know this doesn't work but I have tried other things and I just can't

    seem
    >> to get my head around it and I can't find any information on it!

    >
    >Which bit doesn't work?
    >How many items in the listbox?
    >ps, the first item is 0 and goes to listbox.listCount-1
    >
    >You may want to look at the List property instead of the ItemData Property

    (it defaults
    >to 0 and can only contain a number)
    >
    >You will also need the . before every item that should be part of rst
    >e.g.
    >With rst
    >..AddNew
    >..Fields ....
    >
    >Hope this gets you going on the right track
    >
    >--
    >Dean Earley (dean.earley@icode.co.uk)
    >Assistant Developer
    >
    >iCode Systems
    >
    >
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center