Hi Forum, Access 2000
I have a Procedure that constructs and sends an email and I have added a MsgBox and Response to allow the option to print a Statement to be attached to the email.
This works fine except... in the Statement Printing Function, it also has the option to send an email which of course is not needed this time.
I have added an optional Argument to the Statement Printing Function but the email Function won't allow me to add the option when calling the Statement.
here are some code extracts.
This is on the Email Function and allows the Statement to be called.
This works
but this doesn't:
Where am I going wrong??
The idea is that the code will print the statement and exit before asking if to email as of course, we are already send an email.
But I can't get the code to accept the argument
Here is the Statement Function
and in the code is the If then for the optional Argument
I have a Procedure that constructs and sends an email and I have added a MsgBox and Response to allow the option to print a Statement to be attached to the email.
This works fine except... in the Statement Printing Function, it also has the option to send an email which of course is not needed this time.
I have added an optional Argument to the Statement Printing Function but the email Function won't allow me to add the option when calling the Statement.
here are some code extracts.
This is on the Email Function and allows the Statement to be called.
Code:
Response = MsgBox("Do you want to Print a Loan Statement to attach to this email? Click Yes or No", 68)
If Response = vbYes Then
LoanStatementSingle (CStr(LoanRef))
End If
but this doesn't:
Code:
LoanStatementSingle (CStr(LoanRef), "NoEmail")
Where am I going wrong??
The idea is that the code will print the statement and exit before asking if to email as of course, we are already send an email.
But I can't get the code to accept the argument

Here is the Statement Function
Code:
Public Function LoanStatementSingle(LoanRef As String, Optional DoNotEmail As String) As String
Code:
If DoNotEmail = "NoEmail" Then
'Close database variables
rst.Close
dbs.Close
Exit Function
End If