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?

Status
Not open for further replies.

and

Technical User
Jan 16, 2001
67
GB
Hi.

I have a list box on Form1 populated with fields ClientName, ClientID, with a cmd button to open in Form2 the record selected by the user in the list box.

Form2 has a cmd button that closes it and opens Form1. When I add a new record in Form2 then close it with the cmd button to open Form1, I would like to see this new record show up in the Listbox, but it does not. It shows if I close Form1 and reopen, but how do I get it to show straight away?

Thanks,

Andrew.
 
You description I believe is a little confusing but let me suggest the following:

The command btn on Form1 should open Formf2 with the argument WindowMode(see highlight below) set to acDialog.

Code:
DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][highlight][, windowmode][/highlight][, openargs]

This will suspend the code in the command button from continuing until the form Form2 is closed. Then it will continue with its code. Include the next statement as part of the Form1 command button after the Docmd.Openform

Code:
Me![[i]listboxname[/i]].Requery

This will requery your listbox after the opening of Form2, adding new record in Form2, and closing Form2. No need to close Form1 and/or reopen it. Just leave it in the background, open Form2 for adding records, and close Form2, and then requery the listbox.

Post back if you have any questions.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top