473,320 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Compile Error: ByRef argument type mismatch when generating email

anoble1
245 128KB
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?

4 1159
Seth Schrock
2,965 Expert 2GB
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
245 128KB
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
245 128KB
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
2,965 Expert 2GB
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

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

Similar topics

2
by: Chicken Kebab Abdullah | last post by:
Does anyone know why I get the error 3464 Data type mismatch from the following code. I have a form with a combo(to choose a consumable) and 2 list boxes on it. list on left is all printers...
8
by: Richard Hollenbeck | last post by:
I have two functions (one using the other) where I want to pass into it the character A, B, C, D, or F and have it return a Double indicating the minimum score it takes to get that grade. For...
8
by: mjoytan | last post by:
In my real estate access database, I'm trying to create a report that will give me all the properties that are due for a lease renewal this year. I've been able to use datediff to tell me how...
5
by: daniel.hedz | last post by:
I am generating a usercontrol dynamically successfully, but when I try to find that usercontrol I get a type mismatch. This is what I am doing: //Loading my usercontrol...
2
by: tiiim | last post by:
hi all i created two textboxes to insert date and a button..i hv this following code for that button..but when i ran error msg shows error like 'runtime error 13' & type mismatch..i hv no idea...
3
by: blakerrr | last post by:
Hi everyone, I am trying to export a table to an excel file using vba on a form's button click event. I am getting the error: Compile error: User-defined type not defined. And it highlights...
13
by: forrestgump | last post by:
I am currently trying to use the below VBA to import information into excel from access. This VBA is in the excle sheet:- Public Sub getrs() Dim adoconn As ADODB.Connection Dim adors As...
6
by: travjbad1 | last post by:
I am new to the forum and new to Access, so please be simple and descriptive if possible. I am having a problem with a button on a form that saves, opens a report in pdf, and emails the report to the...
0
by: usharani K | last post by:
Urgent Help !!!!!!!!!!!while compiling the code I am getting the compile error: Compile error: User-defined type not defined in form_load. ---------------------------- Private Sub Form_Load() ...
1
by: Shelley Burke | last post by:
Many thanks for the coding provided in an earlier thread to be able to snapshot document, save as pdf and email it. Unfort I have done everything as instructed and am still having problems. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.