Results 1 to 4 of 4

Thread: Refresh Form

  1. #1
    Join Date
    Jul 2009
    Posts
    4

    Unanswered: Refresh Form

    Hi
    On my main form I have a list box that is based on a query that searches a table of stock and finds all stock available. The problem I am having is that when I submit my form AddNewItem, to add new stock, the list box doesn't update to include this new item without me closing the main form down and re-opening. I tried including a Refresh button on the form but upon clicking this I always get the error "The command or action Refresh isn't available now" So I tried to include a requery code into the code for the Add new stock button which adds the record to the table. I'm not sure that I have put it in the right place though as it still doesn't work. My code is

    Else
    End If
    Forms![Stock].Requery
    Exit_Command36_Click:
    Exit Sub

    Err_Command36_Click:
    MsgBox Err.Description
    Resume Exit_Command36_Click
    End Sub

    Where Stock is my main form. Any suggestions of what else I could try or how to correct this code??

    Thanks for your help!

    Sue

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Try referring directly to the control before you exit, like:

    Forms!Stock!lboName.requery

    See if that works.
    Me.Geek = True

  3. #3
    Join Date
    May 2004
    Posts
    144
    i have this issue too, i've looked at northwind, it update list after insertin.
    & i've checked every where in northwind sample, but i couldnt find how it did this.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Try:

    Refresh
    Forms!MyFormName!MyListBoxName.requery

    (Refresh - so the form's underlying recordset FIRST gets refreshed with any new data changes.)
    (Forms!MyFormName!MyListBoxName.requery - to then requery the listbox.)
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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