requery question

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hello all,
I have a bound form called "Main Form" with an unbound
list box named "List One", with the row source being a
query from one table.
If user double clicks a value on the list box, I write
it's value to the main forms's subform and requery the
subform. If the user needs to add a value to the unbound
list box, I have a command button on "Main Form" to open a
data entry form, called "Form1" to enter a record to the
table which is the record source for "List One".

I am trying to get the unbound list box called "List One"
to requery when the user closes "Form1".
Here is what I have tried, on the Form Close event of Form
1, with no success.
------------------------------
Error, can't find the field '|' referred to in your
expression.

[List One].Requery
------------------------------
Error, There is no field named 'List One' in the current
record.

DoCmd.Requery "List One"
-------------------------------
Error, Can't find the form 'List One' referred to.....

Forms![List One].Requery
------------------------------

How can I call the correct control to requery an unbound
list box?
Any assistance you can provide would be greatly
appreciated.

David
 
David said:
I have a bound form called "Main Form" with an unbound
list box named "List One", with the row source being a
query from one table.
If user double clicks a value on the list box, I write
it's value to the main forms's subform and requery the
subform. If the user needs to add a value to the unbound
list box, I have a command button on "Main Form" to open a
data entry form, called "Form1" to enter a record to the
table which is the record source for "List One".

I am trying to get the unbound list box called "List One"
to requery when the user closes "Form1".
Here is what I have tried, on the Form Close event of Form
1, with no success.
------------------------------
Error, can't find the field '|' referred to in your
expression.

[List One].Requery


You have to specify which object contains the list box:

Forms![Main Form].[List One].Requery

BUT, it is an unecessary complication for Form1 to be aware
of the main form. Your arrangement probably also allows for
a great deal of confusion if a user decided not to enter the
data in Form1 and clicks the focus back to the main form.

The way to force all this to synchronize is for the main
form command button to open form1 in Dialog mode so the
focus can not move anywhere else until Form1 is closed (or
made invisible), This also suspends the VBA code that opens
Form1, which means the Requery can be next statement after
the OpenForm line.

DoCmd.OpenForm "Form1", WindowMode:=acDialog
Me.[List One].Requery
 
Back
Top