Is There a Macro Command To Requery Form Before Printing?

J

JessiRight77

I have a form with several tab controls. I also have a subform on the
main form.

I have placed a command button on the main form that calls a macro that
print-previews a report for the individual record that is currently
displayed. This works fine, EXCEPT I cannot figure out how to make the
macro also refresh the form before it displays the report for a
new/revised record.

I have tried:
1. inserting a "Requery" command (with no argument) before the
"OpenReport" command... but this displays the report for the FIRST
record, not the current record.

2. adding the name of the tab control to the argument section of the
Requery command... but this doesn't work either.

3. making the macro close and open the form... but when the form
re-opens it displays the report for the FIRST record.

With regard to attempt #3, I also thought about making the macro assign
the primary key of the current record to a variable before it closes,
so it can go back to that record when it re-opens... but I don't know
how to do that.

Any thoughts or suggestions?

Thanks,
Jessi
 
A

Al Camp

I never use macros, but you should be able to just do a Refresh just
before opening the report.
That will update any data you might have just changed/added on the form.

Also, you shouldn't be closing your form when you open the report. From
your post, it looks as though you might be opening the report, then closing
the form while the report is still open. When you quit the report, the form
is no longer open.
When you close the form, the report can only run one time against the
value it got from the form. That's why you get the just the First record
after trying the report a second time. Keep the form open....

Use a key value from your open form to filter the records you report on. If
you had a CustID in your report, you would use this criteria for CustID in
the report query...
= Forms!frmYourOpenForm!CustID

That will make the report return just the CustID presently on the open form,
and when you close the report, the form is still at that same record...
ready to continue...

hth
Al Camp
 
J

JessiRight77

Hello, Al:

I do not see a "refresh" command as one of the macro options... only
"requery" (which takes me back to the first record. Is it perhaps
known by a different name?

The only reason I tried closing (and then opening) the form just
*before* printing the report was to refresh the record, but the report
is generated *after* the form has been re-opened. I just can't think
of a way to make it go back to the record I was originally on.

Also, my query already contains the criteria for the primary key of the
form (fldEmployeeID).

Thanks for your help!
Jessi
 
A

Al Camp

OK, that's why I never use macros... too limited.
Some questions to make sure we're on the same page...

Is your button on the main form?
Is your EmployeeID on the main form?
If you change a Main form value... is that OK, or is it just subform fields
that don't update?
What ControlName do you have in your Requery macro?
What settings do you have for your OpenReport macro?

First... while we work on this problem, get rid of any code that closes or
reopens the form, there's no need for that.
Second... all the controls that are on Tabs, are just like they were on the
main form... no different addressing involved.
Third... I just tried an expirement, and... just a macro Requery (with
Control Name blank) was all I needed to report correctly on any "just
edited" MAIN form data.

Try one Requery with no ControlName (to update the main form)
And another Requery with
frmYourSubform
in the Control Name option (to update the subform values)
Then the OpenReport...

Again, I am not that familiar with macros... If we still have trouble, I can
tell you how to do it using VB... which is really the best way to go in the
end.

Hang in there... we'll get it...
Al Camp
 
A

Al Camp

Jessi,
SacCourt has the answer... see his response.
But, (in Access 97) you probably won't find a DoCmd in the macro list.
If so, try RunCommand/Refresh.
hth
Al Camp
 
J

JessiRight77

Thanks so much, guys! I will not be able to test this until Monday,
but it sounds exactly like what I need.

Thanks again,
Jessi
 

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