Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh Listbox data

Status
Not open for further replies.

eavan

Technical User
Aug 6, 2003
51
GB
hi,

i hit a "save" command button which saves data on form1, closes it down, then opens up form2.However, the changes i make on the form1 should be reflected on form2. This data in the list box is not getting updated until i reopen form2 on its own.I tried appending to the macro which runs when the "save" command button is clicked, adding a "run command" - "refresh"..but this doesn't do anything for me.Does anyone know how i can get this data requeried. I know there is a requery function but this doesn't look the correct way to go about it either. Any assistance would be great. Cheers
 
Are you sure you're doing the save first, then open form2? Try putting the following on the OnOpen event of form2:
Me![listboxname].Requery
 
How are ya eavan . . .

Change your save line to:
Code:
[blue]   docmd.RunCommand acCmdSaveRecord[/blue]



Calvin.gif
See Ya! . . . . . .
 
thanks guys for the quick response.

I can't find the OnOpen property of the form.I have also added the code Forms!Assigned test list!List0 in the requery item of the macro. List0 is the name of the listbox, Assigned test list is the name of the form.
 
ace man i have placed this piece of code inside but it is just saving it, which is fine, but i need the new form to refresh with the saved details. I have tried many different things (even though i know it is probably really simple) like runSQL (the query statement, turns out too long a statement), changing the onOpen to requery, but it is not recognising the listbox as a valid argument or something.And a few other things have been tried.

So what i need is to click a command button which opens a form, refreshed with newly saved items.So it needs to run the query again. I wish there was a runQuery command or something which would do the job.Again prob is just i don't know about it.

If i get this it would be great. Cheers
 
Open your form2 in design view. To select the form, click in the little square in the top left corner. When you do this, you will see a little black square. Now when you look at the property sheet, you'll see the title just says FORM and if you click the event tab, you'll see the On Open event. Click in the box next to it and you'll see on the right a little button with three dots. Click this button and click on Code Builder. Type in the code.
Also, I hope you placed Assigned test list inside [ ] when you typed it in. So it looks like this [Assigned test list]. If you have spaces on a form name,tablename, fieldname, then when you reference them you must use [ ]
 
Have you tried to requery using the On Deactivate event of your Form1:

Private Sub Form_Deactivate()

DoCmd.Requery


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top