473,387 Members | 3,810 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,387 software developers and data experts.

How to fix "ByRef argument type mismatch" error when saving as pdf?

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.

Expand|Select|Wrap|Line Numbers
  1. *******************
  2.  
  3. Private Sub View_Report_Click()
  4.  
  5. Dim blRet As Boolean
  6. Dim fileName, Report, msg1 As String
  7. Report = "rptInvoice"
  8. fileName = "C:\Invoices\PDF Files" & Replace(Date, "/", "") & ".pdf"
  9.     DoCmd.OpenReport Report, acViewPreview
  10.     blRet = ConvertReportToPDF(Report, vbNullString, fileName, False, True, 1, "", "", 0, 0)
  11.     DoCmd.Close acReport, Report
  12.     sbSendreturnform fileName
  13.  
  14. End Sub
  15.  
  16. *********************
Getting a "ByRef argument type mismatch" error on this line (highlighting Report):
blRet = ConvertReportToPDF(Report, vbNullString, fileName, False, True, 1, "", "", 0, 0)

The name of my report is rptInvoice and I created the folders to put the PDF into.

I changed the Report to View Report got a syntax error. Changed the report name to ReturnsForm as you had it, get byRef error again :(

Where am I going wrong?
Feb 3 '11 #1
1 3637
Stewart Ross
2,545 Expert Mod 2GB
As a first step please replace your second Dim statement with

Expand|Select|Wrap|Line Numbers
  1. Dim fileName as String, Report as String, msg1 As String
In VBA each variable declaration is separate, even if they are on the same line; Using var1, var2, var3 = sometype does NOT define var1 and var2 to be the same as var3; when no type is specified Variant is the default, which is likely to have caused the error in the call that you highlighted.

-Stewart
Feb 3 '11 #2

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

Similar topics

3
by: Constantine AI | last post by:
Hi i am trying to DELETE a Record if the details do not exist within a table. Here is my code below; Dim strSQL As String Dim strSQL2 As String Dim Reply As String Dim db As...
12
by: mandanarchi | last post by:
First of all I apologise if this is the wrong place to post this; if it fits better somewhere else, could you either tell me, or could a mod move it for me. Thanks. Access 2003 I've set up a...
6
by: mandanarchi | last post by:
Before I begin I want to apologise if my explanations are less than clear; that said, I'll try and be as detailed as possible. Scenario: User (XP OS, running office 2003) - IP = 1xx.x.x.101...
8
by: mandanarchi | last post by:
<?php $td_sku="1088963"; //Following the XML data $xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r <OnlineCheck>\r <Header>\r <BuyerAccountId>----------</BuyerAccountId>\r...
2
by: ZaphodBBB | last post by:
Hi It's about 2 years since I last had to write a database and I'm having difficulty with something I feel should be very simple.. I have a table called tblNew_Equipment with an AutoNumber...
3
by: adigga1 | last post by:
Hello Experts, I'm about to go grey with this dlookup statement: I'm trying to run a dlookup statement, I have the correct expression string, etc. but when I run it under the Immediate window...
17
by: mandanarchi | last post by:
Access 2003; PC with Windows XP; SBS 2003 I tried searching the forums but it came up with a blank page. I searched Google and found an answer; but the 'problem' doesn't relate to our situation!...
5
by: dlblack | last post by:
I have created a form that captures Capital Project Request data for review. After the reviewer has made their decision as to approve or deny the project request, they click an approval button or a...
10
by: Wayneyh | last post by:
Hello Everyone I have tblSales Which has CustomerID, Address1, Address2, Town, County, Postcode, Phone, DateOfVisit Fields and Paid chkbox. I have frmNewSales which is linked to tblSales. What...
7
by: mandanarchi | last post by:
I found the answer last time I was 'playing' with xsl, but I didn't need to use it then and like an idiot, I didn't save where I found it. I've tried Google but it's not coming up with what I need....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.