Hi guys,
I'm a newbee here. Am also newbee in access. I have started a database for our company assets using Access. So far things are going right on track when suddenly i'm faced up with a problem in determining the right VB code.
In my Menu I have 4 buttons: one for viewing a report, one for printing a report, then one for emailing a report, and finally sending a report to file. I was able to successfully perform the viewing and printing a report. When i decided to add the emailing and sending a report, I got lost. I dont know anymore how to go about it. Can anybody help me? I just need to know how to go about emailing and sending a report. Here is my code:
Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_CommandPrevReport_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.
Dim strWhereCategory As String
strWhereCategory = "Plnt_Name = Forms![Plant Data Option Print Form]!PlantListBox1"
Select Case Me!ReportToPrint1
Case 1
'DoCmd.OpenReport "SL Summary Report", PrintMode
If IsNull(Forms![Plant Data Option Print Form]!PlantListBox1) Then
DoCmd.OpenReport "SL Summary Report", PrintMode
Else
DoCmd.OpenReport "SL Summary Report", PrintMode, , strWhereCategory
End If
Case 2
If IsNull(Forms![Plant Data Option Print Form]!PlantListBox1) Then
DoCmd.OpenReport "Fixed Assets Per Plant Report", PrintMode
Else
DoCmd.OpenReport "Fixed Assets Per Plant Report", PrintMode, , strWhereCategory
End If
End Select
Exit_CommandPrevReport_Click:
Exit Sub
Err_CommandPrevReport_Click:
Resume Exit_CommandPrevReport_Click
End Sub
Private Sub CommandClose_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_CommandClose_Click
Dim stDocName As String
Dim stLinkCriteria As String
' Close form.
DoCmd.Close
stDocName = "Main Menu"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CommandClose_Click:
Exit Sub
Err_CommandClose_Click:
MsgBox Err.DESCRIPTION
Resume Exit_CommandClose_Click
End Sub
Private Sub CommandPrevReport_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acPreview
End Sub
Private Sub CommandPrintReport_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acNormal
End Sub
Private Sub ReportToPrint1_AfterUpdate()
' Enable SelectCategory combo box if user selected Sales by Category
' report.
Const conPlantData = 2
If Me!ReportToPrint1.Value = conPlantData Then
Me!PlantListBox1.Enabled = True
Else
Me!PlantListBox1.Enabled = True
End If
End Sub
Private Sub PlantData_GotFocus()
End Sub
Private Sub PlantListBox1_BeforeUpdate(Cancel As Integer)
End Sub
I'm a newbee here. Am also newbee in access. I have started a database for our company assets using Access. So far things are going right on track when suddenly i'm faced up with a problem in determining the right VB code.
In my Menu I have 4 buttons: one for viewing a report, one for printing a report, then one for emailing a report, and finally sending a report to file. I was able to successfully perform the viewing and printing a report. When i decided to add the emailing and sending a report, I got lost. I dont know anymore how to go about it. Can anybody help me? I just need to know how to go about emailing and sending a report. Here is my code:
Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_CommandPrevReport_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.
Dim strWhereCategory As String
strWhereCategory = "Plnt_Name = Forms![Plant Data Option Print Form]!PlantListBox1"
Select Case Me!ReportToPrint1
Case 1
'DoCmd.OpenReport "SL Summary Report", PrintMode
If IsNull(Forms![Plant Data Option Print Form]!PlantListBox1) Then
DoCmd.OpenReport "SL Summary Report", PrintMode
Else
DoCmd.OpenReport "SL Summary Report", PrintMode, , strWhereCategory
End If
Case 2
If IsNull(Forms![Plant Data Option Print Form]!PlantListBox1) Then
DoCmd.OpenReport "Fixed Assets Per Plant Report", PrintMode
Else
DoCmd.OpenReport "Fixed Assets Per Plant Report", PrintMode, , strWhereCategory
End If
End Select
Exit_CommandPrevReport_Click:
Exit Sub
Err_CommandPrevReport_Click:
Resume Exit_CommandPrevReport_Click
End Sub
Private Sub CommandClose_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_CommandClose_Click
Dim stDocName As String
Dim stLinkCriteria As String
' Close form.
DoCmd.Close
stDocName = "Main Menu"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CommandClose_Click:
Exit Sub
Err_CommandClose_Click:
MsgBox Err.DESCRIPTION
Resume Exit_CommandClose_Click
End Sub
Private Sub CommandPrevReport_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acPreview
End Sub
Private Sub CommandPrintReport_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acNormal
End Sub
Private Sub ReportToPrint1_AfterUpdate()
' Enable SelectCategory combo box if user selected Sales by Category
' report.
Const conPlantData = 2
If Me!ReportToPrint1.Value = conPlantData Then
Me!PlantListBox1.Enabled = True
Else
Me!PlantListBox1.Enabled = True
End If
End Sub
Private Sub PlantData_GotFocus()
End Sub
Private Sub PlantListBox1_BeforeUpdate(Cancel As Integer)
End Sub