Results 1 to 7 of 7

Thread: Listbox

  1. #1
    Join Date
    Mar 2004
    Posts
    42

    Unanswered: Listbox

    I have a list box that list user name. When I double click one record I want to open the edit form corresponding to the record seleted. How will do it? Thanks for any help.

  2. #2
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    Theres a couple of ways that spring to mind.

    The easiest would be hto have all the details about the record you want in the listbox, like name,id,1,2,3,4,5 and so on.

    But under column widths you only show the name by changing sizes eg 2.5;0;0;0;0;0;0, make sure that the columncount is the same amount as the fields you have chosen.

    Then under the properties of the combo box, double click you could run a loop to go through all the items and find the 1 that is selected.


    eg:

    For A = 0 To Me.listbox1.ListCount - 1
    if Me.listbox1.Selected(A) = true then

    'get your data here

    the_name = Me.listbox1.Column(0, A)
    the_id = Me.listbox1.Column(1, A)
    the_1 = Me.listbox1.Column(2, A)

    'open your form and populate with these details

    exit for
    end if
    Next



    Then on the new form, you could have a docmd.runsql to update,edit the records?

    Thats one way of doing it, it also means that the user cannot go through any other records.

    Does that help ??

  3. #3
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    Maybe that might have been hard to follow...

    I have create this to help instead.



    Ken

    Access 2000
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2004
    Posts
    42
    Thanks Ken. I will try it.

  5. #5
    Join Date
    Mar 2004
    Posts
    42
    Ken,

    I tried the zip file you send, it works when the fields are unbound to a table. What I really wanted to do, I guess I did not explain it well, is to be able to get the data from the table for editing. For example if I double click the first data on the listbox it will open that data on the edit form just like the file you did but in a bound text that the data already exist on the table. I hope you could help me again.

    Thanks,

    Esm

  6. #6
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    if you open the first form and 'double click' a name, it should open a second form with the data from the table.

    then if you edit anything there and press the 'save button' it will update the table with those changes.

    Is that not what you wanted ?

    ~Ken

  7. #7
    Join Date
    Mar 2004
    Posts
    42
    Thanks for all the help. It works.

Posting Permissions

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