Help with requery/update

M

Mary Beth

I have a form called frmAuthorization with a combo box drop down menu called
RNAsssor. I want to send an email to the Assessor chosen in the combo box
with a report attached containing the data just entered on the form. I have
a macro set up to send the report in an email.

In the On Exit event of the combo box I have:

DoCmd.Requery
DoCmd.RunMacro "mcrInitialAssessment.Initial"

The problem is when I exit the combo box, it does the requery and all of the
data disappears from the form, and the email is not sent. When I take the
DoCmd.Requery out of the code, the email and report macro works, but there is
no data in the report. This only works properly when I reopen the form, look
for the existing record, and choose the assessor again.

Any thoughts, or any additional info you may need to help me?

Thanks,

Mary Beth
 
D

Daryl S

Mary Beth -

I suspect that the data you have entered has not yet been saved when you run
the report, and that would be why the data is blank. If that is the case,
replace the DoCmd.Requery with a Me.Dirty = FALSE, which saves the current
record.

If the combobox is used just to enter data, then I don't know why a requery
would be helpful. (Whereas if an unbound combo box is used to select a
record, then a requery would be needed to display the data based on the combo
box.)
 
M

Mary Beth

Thanks, Daryl, the Me.Dirty = False worked perfectly. What does Me.Dirty
actually mean other than the fact that it saved the record? I used
DoCmd.Requery in order to get the newly entered data into the report that I
am attaching to the email, otherwise either the data was not in the report at
all or the data from a previous record was in the report and the email
trigger wasn't working. So is the Me.Dirty the way to go for this situation
instead of DoCmd.Requery in the future? The combo box is bound and used to
choose a nurse assessor, then the email with the data goes to that assessor.

Thanks,

Mary Beth
 
D

Daryl S

Mary Beth -

The Me.Dirty indicates that there are changes on the form that have not been
saved to the database. Setting Me.Dirty = FALSE saves the changes to the
database. If you run the report (which pulls from the database) while there
are changes in the form only, then those changes are not seen by tghe report,
which only looks at the database.

The DoCmd.Requery does the opposite - it pulls the data from the database
and displays it on the form. This is needed especially in cases where we run
a query to append or update the database rather than saving changes on a
form. The form will not display any data changed in the database unless we
requery the database.

Hope that helps!
 

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

Similar Threads

problems with 'cbo's and requery 2
Combo box change to run Macro 2
REQUERY SUBFORM 4
Requery Combo box in popup form 2
requery 2
Requery combo box 1
Subform requery 2
Requery Form from Combo Box 3

Top