Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    refreshing records (2000)

    I have a listbox with entries, a separate text box shows the number of entries in the listbox (both on form 1) . On clicking an entry in the list a completed record related to that entry appears in another form (form 2). If and when certain work is completed to form2, that record disappears from the list box and the number count text reduces accordingley (form1). The list and number count only change though if I close then reopen form1. How can I have a realtime solution without having to close the form. I have tried adding a refresh button but when pressed a message similar to 'cannot refresh at this time' appears.

    Many thanks Darren.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: refreshing records (2000)

    The answer depends on how you're opening the second form. If you open it as a dialog (popup and modal properties set to Yes), then you can simply add a couple of lines of code after the DoCmd.OpenForm statement that pops up Form2. It would look something like this, assuming that your listbox is called List1 and your textbox Text1.

    Me.List1.Requery
    Me.Text1.Requery

    You would have to replace List1 and Text1 with the actual names of your controls.

    If this isn't the way you pop up the second form or if it is not opened as a dialog, then you'll need to post back so we can give you an alternate method.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: refreshing records (2000)

    Thank you Charlotte. Neither are dialogs, I have simply put that code however on a button and it does the job nicely. Is there a way of doing on a timer, say every 15 mins or so?

    Thanks again Darren.

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

    Re: refreshing records (2000)

    Hi Darren,

    A form has an OnTimer event and a TimerInterval property that you can use for this. TimerInterval is a number in milliseconds; if it is non-zero, the OnTimer event will fire every TimerInterval milliseconds; setting it to 0 disables the OnTimer event.

    So you can set TimerInterval to 900000 (15 minutes = 15*60 seconds = 15*60*1000 milliseconds), and call the code to requery the list box and text box in the OnTimer interval.

  5. #5
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: refreshing records (2000)

    Thank you Hans, could you please give me an example of calling the code the in this instance.

    Regards Darren.

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

    Re: refreshing records (2000)

    Using Charlottes example:

    Private Sub Form_Timer()
    Me.List1.Requery
    Me.Text1.Requery
    End Sub

    Substitute the names of your list box and text box.

  7. #7
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: refreshing records (2000)

    Thanks Hans, that's what I thought I was doing and it didn't work, all is order now.

    Cheers Darren.

Posting Permissions

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