Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Mar 2003
    Location
    Woking, Surrey, England
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update Listbox Contents (2003)

    I have a form in Access 2003, that is bound to a table. On this form I have a couple of listboxes that display data from other tables. The contents of these other tables could be updated by other users of the database at anytime. The listboxes are not bound controls although their source is an SQL statement that includes the primary key value from the currently displayed record in a WHERE clause. The user can select a row in the listbox to open up another form displaying more detailed information about the data in that row.

    I have a timer event attached to the form, set to 'fire' every few seconds to update these two listboxes (to ensure the data displayed is current). The problem I have is that more often than not the requery causes the error "2118: You must save the current field before you run the Requery action." This error doesn't always occur and I've been trying to work out what I'm doing when it does occur. The only thing I can think of is if the user is clicking the mouse at the time the timer function 'fires'. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    I've tried things like adding 'Me.listbox_name.UNDO' to the FORM_TIMER code but found that the values of other controls on the form are cleared at the same time. I can't save the form either because at this point the user might not have enter values in all the fields and therefore the data integrity checking would kick in.

    If anyone has any suggestions as to how to proceed I'd be most grateful.

    Ben

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Listbox Contents (2003)

    Using the On Timer event in a form used for data entry is tricky. I only use the On Timer event for forms that require no user interaction (such as a splash screen).

    Instead of using the On Timer event, I would put the code to requery the list boxes in the On Current event of the form, and perhaps in the On Click event of a "Requery" command button. The list boxes will not be up-to-date all the time, but for my purposes it's good enough if they are requeried when the user moves to another record. In case of doubt, the user can use the command button to force an update.

  3. #3
    New Lounger
    Join Date
    Mar 2003
    Location
    Woking, Surrey, England
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Listbox Contents (2003)

    Thanks Hans. On Timer does seem to be a bit of nightmare!

    I'll give the command button approach a go.

    Thanks again,
    Ben

Posting Permissions

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