Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: How to update a fileld by selectinga row from a listbox?

    Hello

    How do I update a particular field on my form (the form record source is set to tbl1) by selecting a row in a listbox on the same form (the listbox record source set to a related table called tbl2)? The field I want to update on the form is in column 3 in the listbox.

    I want to click a command button to execute the on-click code event to perform the update.

    I cannot figure out the correct method

  2. #2
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    How do I update a particular field on my form (the form record source is set to tbl1) by selecting a row in a listbox on the same form (the listbox record source set to a related table called tbl2)? The field I want to update on the form is in column 3 in the listbox.

    I want to click a command button to execute the on-click code event to perform the update.
    Suppose we call your field to be updated updated_field I assume your list box displays column 3. We call the list box list_box

    The following code will update the field
    me!updated_field=me!list_box.column(2). NOTE, the first column number in a dropdown combo or list boxes start at zero.

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Why not simply use Poppa's code in the Listbox' AfterUpdate event and eliminate the command button?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Aug 2004
    Posts
    364
    Thanks guys, I got it with this -
    Code:
    Forms![visits_frm]![centreID] = Me!List43.Column(0)
    DoCmd****nCommand acCmdRefresh
    I dont know why DBforums puts ** in place of the text though..

Posting Permissions

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