472,353 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

E-mailing current record on form

easydoesit
Hello all,

I am looking for a way to be able to enter data into fields on a form, then be able to e-mail a report that shows only that record.

This is what I have thus far:

At the end of my Form, I have a Command Button. Right now the Command Button has an On Click... [Event Procedure] to basically E-mail a Report.

Here is my Visual Basic code for it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Mail_Report_Button_Click()
  2. On Error GoTo Err_Mail_Report_Button_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "TrainingRequestSingle"
  7.     DoCmd.SendObject acReport, stDocName
  8.  
  9. Exit_Mail_Report_Button_Click:
  10.     Exit Sub
  11.  
  12. Err_Mail_Report_Button_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_Mail_Report_Button_Click
  15.  
  16. End Sub
The Report, "TrainingRequestSingle" basically has all of the Fields that are on the Form.

However, this Report that ends up being e-mailed has all of the Records the Form has total.

I want to to be able to click the Command Button to E-mail the Report which would then show only the current Record being viewed on the Form.

I have another Command Button on the same Form that Prints the current Record only (and not all Records) with success. I have tried manipulating it to work for my E-mailing situation with no success, however.

Here is the Visual Basic code I used in that situation:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Record_Button_Click()
  2. On Error GoTo Err_Print_Record_Button_Click
  3.  
  4.  
  5.     DoCmd.OpenReport "TrainingRequestSingle", acViewPreview, , _
  6.     "[TrainingRequestID]=Forms![Training Request Form]!TrainingRequestID"
  7.  
  8. Exit_Print_Record_Button_Click:
  9.     Exit Sub
  10.  
  11. Err_Print_Record_Button_Click:
  12.     MsgBox Err.Description
  13.     Resume Exit_Print_Record_Button_Click
  14.  
  15. End Sub
The name of my form is:
Training Request Form

The name of my report is:
TrainingRequestSingle

The name of my e-mail report command button is:
Mail Report Button

I am using Microsoft Access 2002.
Aug 27 '07 #1
2 2075
JConsulting
603 Expert 512MB
Hello all,

I am looking for a way to be able to enter data into fields on a form, then be able to e-mail a report that shows only that record.

This is what I have thus far:

At the end of my Form, I have a Command Button. Right now the Command Button has an On Click... [Event Procedure] to basically E-mail a Report.

Here is my Visual Basic code for it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Mail_Report_Button_Click()
  2. On Error GoTo Err_Mail_Report_Button_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "TrainingRequestSingle"
  7.     DoCmd.SendObject acReport, stDocName
  8.  
  9. Exit_Mail_Report_Button_Click:
  10.     Exit Sub
  11.  
  12. Err_Mail_Report_Button_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_Mail_Report_Button_Click
  15.  
  16. End Sub
The Report, "TrainingRequestSingle" basically has all of the Fields that are on the Form.

However, this Report that ends up being e-mailed has all of the Records the Form has total.

I want to to be able to click the Command Button to E-mail the Report which would then show only the current Record being viewed on the Form.

I have another Command Button on the same Form that Prints the current Record only (and not all Records) with success. I have tried manipulating it to work for my E-mailing situation with no success, however.

Here is the Visual Basic code I used in that situation:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Record_Button_Click()
  2. On Error GoTo Err_Print_Record_Button_Click
  3.  
  4.  
  5.     DoCmd.OpenReport "TrainingRequestSingle", acViewPreview, , _
  6.     "[TrainingRequestID]=Forms![Training Request Form]!TrainingRequestID"
  7.  
  8. Exit_Print_Record_Button_Click:
  9.     Exit Sub
  10.  
  11. Err_Print_Record_Button_Click:
  12.     MsgBox Err.Description
  13.     Resume Exit_Print_Record_Button_Click
  14.  
  15. End Sub
The name of my form is:
Training Request Form

The name of my report is:
TrainingRequestSingle

The name of my e-mail report command button is:
Mail Report Button

I am using Microsoft Access 2002.

couple of ways really...easiest would be to modify the report's recordsource. It uses a temp queery that you'll need to assign as the recordsource of your report.

Expand|Select|Wrap|Line Numbers
  1. Function MailMyRecord()
  2. On Error Resume Next
  3. Dim qDf As dao.QueryDef
  4. DoCmd.DeleteObject acQuery, "tempqry"
  5. Set qDf = CurrentDb.CreateQueryDef("TempQry", "Select * from myrecordsource where ID=" & Me.ID)
  6. stDocName = "TrainingRequestSingle"
  7.     DoCmd.SendObject acReport, stDocName
  8. End Function
  9.  
I assume you know how to address the e-mail and all that.
J
Aug 28 '07 #2
couple of ways really...easiest would be to modify the report's recordsource. It uses a temp queery that you'll need to assign as the recordsource of your report.

Expand|Select|Wrap|Line Numbers
  1. Function MailMyRecord()
  2. On Error Resume Next
  3. Dim qDf As dao.QueryDef
  4. DoCmd.DeleteObject acQuery, "tempqry"
  5. Set qDf = CurrentDb.CreateQueryDef("TempQry", "Select * from myrecordsource where ID=" & Me.ID)
  6. stDocName = "TrainingRequestSingle"
  7.     DoCmd.SendObject acReport, stDocName
  8. End Function
  9.  
I assume you know how to address the e-mail and all that.
J
Thanks for your reply, but I am so lost I don't even know where to begin, sadly.
Sep 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tony | last post by:
I have a form in access that has 5 fields for a certain record: 1)Date mailed, 2)Date received, 3)Date completed 4)Foreign Content amount and...
2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button...
1
by: Richard Coutts | last post by:
I have a Continuous Form where each record has a button that activates another form that simplifies entering values into the record. The activated...
3
by: Maria | last post by:
Is there another way to delete the current record in a subform from the main form, another subform or a sub-subform other than setting focus on a...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox....
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset...
5
by: eighthman11 | last post by:
Hi everyone: This is probably a pretty simple problem but it is driving me nuts. Using Access 2000. I have a continuous form which list several...
2
by: Tom Clavel | last post by:
Scratching my head. I am using the filter property on a combo box .AfterUpdate event to get to a single client record. This is causing a some...
1
by: Jeff Karli | last post by:
I think I now understand how to use this forum. I hope I am following the rules now. I am a college student working on a database project that...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.