473,427 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,427 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 2127
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 5)record number. If the foreign content (FC)is >15% of...
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 form. The command button 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 wizard (result: DoCmd.GoToRecord , , acNext). I...
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 form has the equivalent of a "Done" button. I'd...
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 field in the subform and using run command...
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. Cuurrent record should be the same as the value in the...
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 and current record. I can do the recordset set...
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 thousand inventory items. The user can enter a...
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 strange behavior: As I enter a subform, I get a no...
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 requires some VBA coding for the Event Procedures and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.