By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

Compile Error: ByRef argument type mismatch when generating email

anoble1
100+
P: 223
I have an older database I am working with. Need some help.
I have a function that creates a .SNP and opens a new email message and fills out the To and CC and attaches an attachment.

No matter where I try to debug it jumps straight to this. It keeps stopping at
Expand|Select|Wrap|Line Numbers
  1. outFileName
Usually it will let me debug, but not in this instance.

I've checked the path and the permissions look fine on that particular folder. I just keep getting ByRef argument type mismatch on that outFileName. Ideas?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command14_Click()
  2. Dim FDest As String
  3. Dim SnapshotFile As String
  4. Dim ContNum As String
  5. Dim ContName As String
  6. Dim AuthNumber As String
  7. Dim AuthDate As String
  8. Dim CrewAuthName As String
  9. Dim outFileName() As String
  10. End Sub
  11.  
  12. If Company.Value = 1 Or Company.Value = 1 Then
  13.     ReDim Preserve outFileName(0)
  14.     outFileName(0) = "C:\Temp\" & ContractorName.Value & " Crew Authorization " & cmbContractID.Column(1, cmbContractID.ListIndex) & "-" & AuthNum.Value & " (" & Forms!frmCrewAuthorization!NAME.Value & "'s Crew).snp"
  15.  
  16.     DoCmd.OutputTo acOutputReport, "rptCrewAuthorization", acFormatSNP, outFileName(0), False
  17.     GenerateEmail "anoble@*******.com", ContractorName.Value & " Crew Authorization " & cmbContractID.Column(1, cmbContractID.ListIndex) & "-" & AuthNum.Value & " - Starting " & Forms!frmCrewAuthorization!AuthDate.Value, Forms!frmCrewAuthorization!NAME.Value & "'s Crew" & vbCrLf & vbCrLf, outFileName, False
  18. End If
  19.  
Feb 13 '15 #1

✓ answered by Seth Schrock

Why are you using an array when you only have one slot in the array? Is the error on line 13, 14, or 16?

Share this Question
Share on Google+
4 Replies


Seth Schrock
Expert 2.5K+
P: 2,939
Why are you using an array when you only have one slot in the array? Is the error on line 13, 14, or 16?
Feb 13 '15 #2

anoble1
100+
P: 223
Line 17 is where the error is.
I have a long lengthy list of If statements that keep going for misc companies.
Feb 13 '15 #3

anoble1
100+
P: 223
You bring a good point. I updated some lines.
Now I don't get that error anymore! Thanks for the help!
Expand|Select|Wrap|Line Numbers
  1. outFileName = "K:\Anoble\Authorizations\" & ContractorName.Value & " Crew Authorization " & cmbContractID.Column(1, cmbContractID.ListIndex) & "-" & AuthNum.Value & " (" & Forms!frmCrewAuthorization!Name.Value & "'s Crew).snp"
  2. DoCmd.OutputTo acOutputReport, "rptCrewAuthorization", acFormatSNP, outFileName, False
  3. GenerateEmail "anoble@*****.com", ContractorName.Value & " Crew Authorization " & cmbContractID.Column(1, cmbContractID.ListIndex) & "-" & AuthNum.Value & " - Starting " & Forms!frmCrewAuthorization!AuthDate.Value, Forms!frmCrewAuthorization!Name.Value & "'s Crew" & vbCrLf & vbCrLf, outFileName, False
  4.  
Feb 13 '15 #4

Seth Schrock
Expert 2.5K+
P: 2,939
The reason is that in line 17, you passed it the whole array, instead of outFileName(0). So it would have probably worked even using the array if you had specified which "slot" of the array to use.
Feb 14 '15 #5

Post your reply

Sign in to post your reply or Sign up for a free account.