-
Delete records
Hi,
I was trying to build up a form where i enter a data and when i submit the button, the after event code makes the data entered, emails in XLS format to a group of people in outlook email via sendobject function.
However, the problem i am facing is that when i am sending the data, all the previous entries are also stored in the documents which is being sent in the email..
do i need to have a delete query in the 'before update' of form??? if yes, then what should be the code for that?
thanks
-
Do you need the previous data entered in the table?
If no, you could delete the table when the form loads. But remember with the form open that you must save the last entry added or modified before you submit the data as the last change or addition is held in memory unitl the form closes or you move off the record.
If yes, use another form to obtain your date range etc. the submit the data.
Allan
-
Thanks Allen
Hi Allen,
Thanks for your reply...
i had put the code for the button click which said...
rivate Sub Save_Record_Click()
On Error GoTo Err_Save_Record_Click
DoCmd.GoToRecord , , acLast
Exit_Save_Record_Click:
Exit Sub
Err_Save_Record_Click:
MsgBox Err.Description
Resume Exit_Save_Record_Click
End Sub
apart from that....i have put the following code in the after event of the form
Private Sub Form_AfterUpdate()
DoCmd.SendObject acSendForm, "TR Account Creation Intimation", acFormatXLS, _
"Abc@ABC.COM", , _
, "abc Mail - " & Me.Status & "- " & Me.Account_Name, "This is an automated mail", False
End Sub
So, what do i need to do??
should i put a code in the before event of the form....which would maybe delete all the data before i click the button>?
and what code should i put...i am very confused about that...
-
When the form opens - delete the table
Private Sub Form_Open()
DELETE The table code goes here
End Sub
When the form closes try the following code, note I have made changes as shown in RED
Private Sub Form_Close()
Docmd.Close
DoCmd.SendObject acSendTable, "Name of the table goes here", acFormatXLS, _
"Abc@ABC.COM", , _
, "abc Mail - " & Me.Status & "- " & Me.Account_Name, "This is an automated mail", False
End Sub
Docmd.Close will close the form and any changes to the current record is saved or if a there is a new record it is also saved when the form closes, then the email is sent
In your code using acForm you are sending the form not the data.
Allan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|