Add new record and email report from one command button on a form

M

mgourley

I have set up a work order database. On the Work Order Submission form I have
a command button that adds the record to the table. I also have a button to
email the Submission Report. When the user fills out the form and clicks the
Add button the record is added to the table. The user then has to scroll to
have the record reappear in the form and then click the Email command button.
This works fine but I want to make this a one click operation. Any
suggestions?
 
S

Stockwell43

In your email button place this at the end of your code (in other words, just
above End Sub)

DoCmd.GoToRecord , , acNewRec
 
M

mgourley

Thanks for the suggestion. That solves half the problem. I have a filter on
the report that will be emailed to limit the report to just the current
record. The filter is:
[ID] = Forms![WO Submission]![ID]
where ID is the Primary Key for that record. If the record has not yet been
added to the table and thus has no primary key, the report to be emailed
will contain no record info.
I'm thinking I may have to use a temporary table but I'm clueless about how
to make that work.
Any other suggestions?
 
S

Stockwell43

I'm sorry, I wish I could give you an answer to your problem but
unfortunately, I'm not sure what you would have to do. Although, if your
looking to just pull the information from the current record into the email,
depending on how many fields you have you could code it. That's what I do; I
code all the fields I want added to the message body and it seems to work
fine. Just a thought is all. I'm sure someone out here can help you much
better as these guys are very knowledgable with access.

Hope this information helps!

mgourley said:
Thanks for the suggestion. That solves half the problem. I have a filter on
the report that will be emailed to limit the report to just the current
record. The filter is:
[ID] = Forms![WO Submission]![ID]
where ID is the Primary Key for that record. If the record has not yet been
added to the table and thus has no primary key, the report to be emailed
will contain no record info.
I'm thinking I may have to use a temporary table but I'm clueless about how
to make that work.
Any other suggestions?

Stockwell43 said:
In your email button place this at the end of your code (in other words, just
above End Sub)

DoCmd.GoToRecord , , acNewRec
 
M

mgourley

I knew it didn't have to be that difficult.
After posting this I went back and started looking at the form and noticed
the After Update property. I placed the code from my email command button
stDocName = "Work Order Submission"
DoCmd.SendObject acReport, stDocName
in the Event Procedure. Voila. When the user clicks the "Add Work Order"
button, the record is added to the table, the email program opens up and the
report with the info from the record data is right there waiting to be sent.
Good thing I'm pretty much an Access For Dummies user, otherwise I'd be
kicking myself for not figuring this out a month ago.

Stockwell43 said:
I'm sorry, I wish I could give you an answer to your problem but
unfortunately, I'm not sure what you would have to do. Although, if your
looking to just pull the information from the current record into the email,
depending on how many fields you have you could code it. That's what I do; I
code all the fields I want added to the message body and it seems to work
fine. Just a thought is all. I'm sure someone out here can help you much
better as these guys are very knowledgable with access.

Hope this information helps!

mgourley said:
Thanks for the suggestion. That solves half the problem. I have a filter on
the report that will be emailed to limit the report to just the current
record. The filter is:
[ID] = Forms![WO Submission]![ID]
where ID is the Primary Key for that record. If the record has not yet been
added to the table and thus has no primary key, the report to be emailed
will contain no record info.
I'm thinking I may have to use a temporary table but I'm clueless about how
to make that work.
Any other suggestions?

Stockwell43 said:
In your email button place this at the end of your code (in other words, just
above End Sub)

DoCmd.GoToRecord , , acNewRec

:

I have set up a work order database. On the Work Order Submission form I have
a command button that adds the record to the table. I also have a button to
email the Submission Report. When the user fills out the form and clicks the
Add button the record is added to the table. The user then has to scroll to
have the record reappear in the form and then click the Email command button.
This works fine but I want to make this a one click operation. Any
suggestions?
 
S

Stockwell43

So your saying there was no code in your event procedure? mgourley, shame on
you! :blush:) Glad you got it fixed. Not to worry, I can't tell you how many times
things like happen to me and still do!

Have a good weekend not that you can rest! :blush:)

mgourley said:
I knew it didn't have to be that difficult.
After posting this I went back and started looking at the form and noticed
the After Update property. I placed the code from my email command button
stDocName = "Work Order Submission"
DoCmd.SendObject acReport, stDocName
in the Event Procedure. Voila. When the user clicks the "Add Work Order"
button, the record is added to the table, the email program opens up and the
report with the info from the record data is right there waiting to be sent.
Good thing I'm pretty much an Access For Dummies user, otherwise I'd be
kicking myself for not figuring this out a month ago.

Stockwell43 said:
I'm sorry, I wish I could give you an answer to your problem but
unfortunately, I'm not sure what you would have to do. Although, if your
looking to just pull the information from the current record into the email,
depending on how many fields you have you could code it. That's what I do; I
code all the fields I want added to the message body and it seems to work
fine. Just a thought is all. I'm sure someone out here can help you much
better as these guys are very knowledgable with access.

Hope this information helps!

mgourley said:
Thanks for the suggestion. That solves half the problem. I have a filter on
the report that will be emailed to limit the report to just the current
record. The filter is:
[ID] = Forms![WO Submission]![ID]
where ID is the Primary Key for that record. If the record has not yet been
added to the table and thus has no primary key, the report to be emailed
will contain no record info.
I'm thinking I may have to use a temporary table but I'm clueless about how
to make that work.
Any other suggestions?

:

In your email button place this at the end of your code (in other words, just
above End Sub)

DoCmd.GoToRecord , , acNewRec

:

I have set up a work order database. On the Work Order Submission form I have
a command button that adds the record to the table. I also have a button to
email the Submission Report. When the user fills out the form and clicks the
Add button the record is added to the table. The user then has to scroll to
have the record reappear in the form and then click the Email command button.
This works fine but I want to make this a one click operation. Any
suggestions?
 

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