converted macro to VB--now what??????

nanny

Registered User.
Local time
Yesterday, 16:30
Joined
Dec 16, 2008
Messages
19
I have a macro which will e-mail 14 reports from a command button. Would rather have VB code for some reason---so I did that thing where you convert the macro----now I do not know how to use it. I tried to copy and paste it into the on clinc property of the cmd button but it does'nt work. Any help is appreciated.
 
As long as you didn't include the first and last lines, it should probably work. It would help to see the code and get a clarification of "doesn't work".
 
This is what I copied and pasted -It's starting to scare me!!!!



Private Sub Command29_Click()
On Error GoTo mcre_mailreports_mcre_mailreports_Err
If (Reports!SummaryrptAdmissions) Then
DoCmd.SendObject acReport, "SummaryrptAdmissions", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "rptAdmissions", "", False, ""
End If
If (Reports!SummaryrptOngoingDocumentation1) Then
DoCmd.SendObject acReport, "SummaryrptOngoingDocumentation1", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptOngDocumentation1", "", False, ""
End If
If (Reports!SummaryrptOngoingDocumentation2) Then
DoCmd.SendObject acReport, "SummaryrptOngoingDocumentation2", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptOngDocumentation2", "", False, ""
End If
If (Reports!SummaryrptOngoingDocumentation3) Then
DoCmd.SendObject acReport, "SummaryrptOngoingDocumentation3", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptOngDocumentation3", "", False, ""
End If
If (Reports!SummaryrptVolunteers) Then
DoCmd.SendObject acReport, "SummaryrptVolunteers", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptPtCareVolunteers", "", False, ""
End If
If (Reports!SummaryrptDischargeTransferRevocation) Then
DoCmd.SendObject acReport, "SummaryrptDischargeTransferRevocation", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptDischargeTransferRevocation", "", False, ""
End If
If (Reports!SummaryrptDeathBereavement) Then
DoCmd.SendObject acReport, "SummaryrptDeathBereavement", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptDeathBereavement", "", False, ""
End If
If (Reports!SummaryrptHomeVisits) Then
DoCmd.SendObject acReport, "SummaryrptHomeVisits", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptHomeVisits", "", False, ""
End If
If (Reports!SummaryrptQualityIndicatorstCustomerService) Then
DoCmd.SendObject acReport, "SummaryrptQualityIndicatorsCustomerService", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptPICustomerService", "", False, ""
End If
If (Reports!SummaryrptPersonnelManagementClinical) Then
DoCmd.SendObject acReport, "SummaryrptPersonnelManagementClinical", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptPMClinical", "", False, ""
End If
If (Reports!SummaryrptPersonnelManagementCommunityRelations) Then
DoCmd.SendObject acReport, "SummaryrptPersonnelManagementCommunityRelations", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptPMCR", "", False, ""
End If
If (Reports!SummaryrptPersonnelManagementVolunteers) Then
DoCmd.SendObject acReport, "SummaryrptPersonnelManagementVolunteers", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptPMVolunteers", "", False, ""
End If
If (Reports!SummaryrptAdministrationandManagement) Then
DoCmd.SendObject acReport, "SummaryrptAdministrationandManagement", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptAdministrationandManagement", "", False, ""
End If
If (Reports!SummaryrptPerformanceImprovementEducation) Then
DoCmd.SendObject acReport, "SummaryrptPerformanceImprovementEducation", "SnapshotFormat(*.snp)", "awilson@southerncareinc.com", "", "", "rptPerformanceImprovementEducation", "", False, ""
End If

mcre_mailreports_mcre_mailreports_Exit:
End Sub
mcre_mailreports_mcre_mailreports_Err:
MsgBox Error$
Resume mcre_mailreports_mcre_mailreports_Exit
End Sub
End Sub
 
And what does "doesn't work" mean? Do you get an error, and if so what is it? Off the top:

mcre_mailreports_mcre_mailreports_Exit:
Exit Sub

and delete one of the End Sub lines at the end.
 
I made the changes you suggested. The first thing after I clicked the e-mail report button was "The report name 'summaryrptAdmissions' you entered is misspilled or refers to a report that isn't open or doesn't exist. ---The spelling was correct so I opened the report, left it opened and clicked the button again with a response of "Wrong number of arguments or invalid property assignment". Thanks
 
decided to stay with the macro-it works- the only that is a little distasteful is the e-mail recipient will have to open 14 e-mails. Would be nice to send all reports to one folder on my desktop and e-mail the one folder. any suggestions? :rolleyes:
 

Users who are viewing this thread

Back
Top Bottom