Command Button to run a query that updates a report to preview

M

Mike

Hello all! I'd like to thank all of you that are helping guys like me get
ahead in Access. I was wondering if there was a way that I could create a
Command Button that will first run an update table query and once that query
has successfully run, I would like for this command to also bring up a print
preview of a report that was just updated by this command button. Is this
possible and if so, how could I make this happen?
 
M

Maurice

Mike,

I assume your report is bound to the updated table so that wouldn't be to
hard.

Create the update query and save the query.
Create a button on your form and place the following in de code behind the
button (between the Sub and End Sub)

----------------
DoCmd.SetWarnings False '- prevent the message you are about to....
DoCmd.OpenQuery "your queryname here"
DoCmd.SetWarnings True '- set warnings back on...

DoCmd.OpenReport "your reportname here.."

------------
if you don't want the hassle of the warnings and want to use Jet directly
then place the following in the code:


Currentdb.Execute "your queryname here", dbFailOnError
DoCmd.OpenReport "your reportname here.."

hth
 
M

Mike

Hi Maurice, thanks soo much for your help! It worked like a charm. You were
very helpful. Thanks again and have a great day!

Michael
 

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