Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2009
    Posts
    5

    Unanswered: Editing a row in a listbox

    Hi,
    On my form i have multiple listboxes. I would like to be able to select a row and click on a button which will open a new form with the details so i can edit the data that has been selected.

    At the moment all the data from the table is showing and not the specific record that is selected.

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Quote Originally Posted by SnowFlakes87
    At the moment all the data from the table is showing and not the specific record that is selected.
    Well, that tells me you're probably on the right track
    It sounds to me like you need to look at the WHERE filter of the form. Specifically, if you are able to load your form from the button click event, you're probably using something like
    Code:
    docmd.OpenForm
    Take a look at the WHERE filter argument of that method.
    Me.Geek = True

  3. #3
    Join Date
    Jan 2009
    Posts
    5
    Hi, i checked the where clause and i think its fine.

    This is what i've written:

    DoCmd.OpenForm "frmName", , , "fieldname = Me.listboxname.Column(3)", , , OpenArgs

    The ID column is bound to column 3

    Do i need to set a recordsource on the main form? I have not done so because i have several listboxes.





    Quote Originally Posted by nckdryr
    Well, that tells me you're probably on the right track
    It sounds to me like you need to look at the WHERE filter of the form. Specifically, if you are able to load your form from the button click event, you're probably using something like
    Code:
    docmd.OpenForm
    Take a look at the WHERE filter argument of that method.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The syntax can vary based on the data type:

    Open a second form to the record

    The first form does not need a record source, the form being opened does.
    Paul

  5. #5
    Join Date
    Jan 2009
    Posts
    5
    i tried the method shown but it still doesnt show the right record. It shows the first record in the table rather than finding the same ID and showing that record.




    Quote Originally Posted by pbaldy
    The syntax can vary based on the data type:

    Open a second form to the record

    The first form does not need a record source, the form being opened does.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    What exactly did you try, and what is the data type of the field in the table?
    Paul

  7. #7
    Join Date
    Jan 2009
    Posts
    5
    The field type is text

    this is the code

    DoCmd.OpenForm "frmEditDetails", , , "treatmentID = '" & Me.lsttreatment.Column(3) & "'"

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You realize that the column property is zero based, so the third column would be (2)? Is the column property of the listbox set to at least 3? Have you set a breakpoint and examined the value being returned?
    Paul

  9. #9
    Join Date
    Jan 2009
    Posts
    5
    i debugged it and checked the value of Me.lsttreatment.Column(3) and it shows the treatmentID that i selected. But when the edit form opens it doesnt show the right record

    Quote Originally Posted by pbaldy
    You realize that the column property is zero based, so the third column would be (2)? Is the column property of the listbox set to at least 3? Have you set a breakpoint and examined the value being returned?

  10. #10
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Can you post the db?
    Paul

Posting Permissions

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