requery works at breakpoint but not otherwise

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?
 
M

Marshall Barton

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.
 
S

seeker

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top