requery works at breakpoint but not otherwise

  • Thread starter Thread starter seeker
  • Start date Start date
S

seeker

The following code runs when a button is clicked.
DoCmd.OpenQuery "qryEditEmployerSpelling", acViewNormal, acEdit
emp_id.Requery
As you can see a query is opened giving the user the ability to change the
spelling of an employer. Then the combo box used to select the employer is
requeried so that the changes can be seen. The problem is that the changes
are not evident until the button is clicked again and then the previous
change is seen. User wants the change to be seen when query is closed and a
return to the form occurs. When I run the code step by step it does exactly
that but when I take the breakpoint out the change does not show until later.
What change is needed to accomplish what is needed?
 
seeker said:
The following code runs when a button is clicked.
DoCmd.OpenQuery "qryEditEmployerSpelling", acViewNormal, acEdit
emp_id.Requery
As you can see a query is opened giving the user the ability to change the
spelling of an employer. Then the combo box used to select the employer is
requeried so that the changes can be seen. The problem is that the changes
are not evident until the button is clicked again and then the previous
change is seen. User wants the change to be seen when query is closed and a
return to the form occurs. When I run the code step by step it does exactly
that but when I take the breakpoint out the change does not show until later.
What change is needed to accomplish what is needed?


OpenQuery is asynchronous so your code proceeds before the
user has made the change. Instead, you should open a form
in Dialog mode so your code waits for the form to be closed
(or made invisible).

You could base the form on the same query, but if the code
"knows" which record will be edited, it's probably better to
filter the data to the single record.
 
Thank you that seems to work.
Marshall Barton said:
OpenQuery is asynchronous so your code proceeds before the
user has made the change. Instead, you should open a form
in Dialog mode so your code waits for the form to be closed
(or made invisible).

You could base the form on the same query, but if the code
"knows" which record will be edited, it's probably better to
filter the data to the single record.
 
Back
Top