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

    Unanswered: Update query via listbox and textbox?

    I have a table (tblone) and a query with the fields of the table (qryone)

    On a form I have a listbox which displays all the fields from qryone.

    I want to put a textbox on the form so I can alter colum(2) of the listbox, ie enter text into the textbox and click a command button and the change appears in column(2) of the listbox. So Im basically updating the table and query. The form and listbox both have qryone as their record source.

    The problem is at the moment I have ten rows in the listbox. If I select any row and enter a value into the textbox, it saves the value to the first row of the listbox - not the row I have selected(the first row of the query and table).

    How do I make the textbox and command button save to the row and column I have selected in my listbox?
    Last edited by moss2076; 02-06-05 at 10:27.

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    in your query set a sort statement on first column. When you refresh the query it will maintian the sort order you set. If your first column is text and you don't want an alphbetical sort you may need to ad an 'Order' column and number each row in the order you want sorted then sort on the numeric 'Order' column.


    /
    ~

    Bill

  3. #3
    Join Date
    Aug 2004
    Posts
    364
    hi Bill thanks for the reply, but that hasnt sorted it.

    I need to point the textbox to the row I have selected in the listbox - If I select record number 3 (ie row 3) I want to enter text into the textbox and when I save it will update column(2) in the query and listbox.

  4. #4
    Join Date
    Feb 2004
    Posts
    533
    Quote Originally Posted by moss2076
    hi Bill thanks for the reply, but that hasnt sorted it.

    I need to point the textbox to the row I have selected in the listbox - If I select record number 3 (ie row 3) I want to enter text into the textbox and when I save it will update column(2) in the query and listbox.
    If you identify the record from your table by an ID in the listbox then you can create a recordset and update the field in the table via a recordset. The same table the listbox is based on. You can then Requery the list box (frm.lstName.Requery) When I requeried just the list not the form the list selection did not change. If you have to requery the form then you could use an event or command button click action with these steps:

    1. instantiate a variable with the list index
    2. update the table with your the textbox value by a recordset
    3. requery the form
    4. move the list selection to the previous selected index held in the variable

    I did a test form to demo the process, using only the list.requery.
    file attached.
    Attached Files Attached Files
    ~

    Bill

Posting Permissions

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