Print MS Access Table into pdf using vb6.0 - ms-access

I have saved my output (normally varies every time) as MS Access Table. I need to submit the table content to my client as "pdf" file. Can someone help me print or export MS Access table content into pdf format.
I tried DataReport in VB6.0 and I couldn't save output into pdf. I am getting "Report width is larger than the paper width".
When I manually export MS Access table to pdf, there was no error.
My print DataReport coding is here,
With DataReport
.ExportFormats.Add "OutputReport4", rptFmtText, "OutputReport (*.pdf)", "*.pdf"
.ExportReport "OutputReport4", , False, True, rptRangeAllPages
.PrintReport True
End With
Can some one help me please...

Related

MS Access - Changed query to add more columns, but Macro running that query still exports only the previously-existing columns

We have had a small MS Access mdb for years.
I added a few columns to a query which a Macro runs, and when the query is run separately it outputs the new columns.
The query is also run from a Macro, under an "ImportExportText" section when I look at the macro in design mode.
There's not much to that section - transfer type is "export fixed width", Specification Name is 1, File name is the full path to where the text file should be exported to, Has Field Names = No.
I run the macro, it outputs the txt file, but the txt file doesn't include the new columns.
Any ideas? Thanks!

MS Access 2013 saved exports not saving to MSysIMEXSpecs table

I am working on an Access 2013 database that someone else created. It has a module that exports several reports as PDF files to a specific folder. Some of the reports are exporting successfully but 3 of them aren't. An example of the code used is as follows:
DoCmd.RunSavedImportExport "Export-rptJobsToClose_FS2"
I receive an error that the database can't save the output data to the file you've selected. I realize that the path is saved in the "Export-rptJobsToClose_FS2" saved export. I would like to see the path so I have tried opening the MSysIMEXSpecs table but when I do, it is totally empty. So is the corresponding table MSysIMEXColumns. If I create a new SavedExport definition and use the same name as the one in the code, I get the message that it already exists. How is that possible that it already exists when those system tables are empty? I have tried creating saved exports with new names, but if they don't work I can't reuse those names as I get the message that they already exist. So, I have to keep thinking of new names and can't see any information about the Saved Exports that I have already created. Thanks for any help.
MSysIMEX* tables contain import specifications for correct data transfer. Saved import-exports stored in other place. You can see all names of saved imports/exports using menu External Data -> Saved Imports/Exports, there you can also see and edit destination path and import/export name.
Thru VBA you can reach the collection of saved imports/exports by using collection CurrentProject.ImportExportSpecifications, destination path stored in XML attribute of each Item.
The code below prints all existing import-export specifications
Dim ie As ImportExportSpecification
For Each ie In CurrentProject.ImportExportSpecifications
Debug.Print ie.Name
Next
Saved import/exports in Access are not the same thing as import/export specifications. If you want to see the saved import/export definition, you can dump it by typing the following command into the Immediate window.
? CodeProject.ImportExportSpecifications(*SpecificationName*).XML

How do I highlight all text and wrap in data exported from Access to Excel using VBA?

I am using VBA in Access to export a file into Excel and format the text in Excel. I am trying to highlight all data in Excel (once it has been exported) and then wrap that data using VBA code in Access.
How would I get this task completed?
Trying to use the code below is not working. The data starts in cell A1 and should end with the end xlright ans down (meaning, I do not have a set column or row where the data ends).
objApp.ActiveWorkbook.Worksheets(1).Activate
objApp.ActiveWorkbook.Worksheets(1).Range("A1").Select
objApp.ActiveWorkbook.Worksheets(1).Selection.End(xlToRight).Select
objApp.ActiveWorkbook.Worksheets(1).Selection.End(xlDown).Select
objApp.Selection.WrapText = True
Probably the following would work clearly for you:
objApp.ActiveWorkbook.Worksheets(1).usedrange.wraptext=true

Creating a report that will display a number of images from filenames in a table

I have a VBScript that I use to read an XML file and populate a couple of tables in Access 2010. The VBScript also copies jpg files from a card reader to a location on the server. The VBScript creates a unique folder based on date/time...the folder location of each image name is written to the database as one of the fields in UNC path\filename.jpg notation.
I have a primary database and the transaction (images) are referenced in the second database. I have created a relationship as well...
I am able to build my report in Access from data from both the tables, however, I'd like to automate a print job that grabs the last entry to the primary database, it's associated images (up to 10...but not 10 in every case) and print them out. When I try to build the report I cannot figure out how to use a query result of the field with the filenames to display on the report.
You can do what you describe using an Image control and a line of VBA code. For a sample table named [ImageLocations]
ImageLocation
-----------------------------------
\\SERVER\Public\Pictures\image1.jpg
\\SERVER\Public\Pictures\image2.jpg
I created a report with that table as the Record Source, dropped the [ImageLocation] field onto the Detail band, and added an Image control. I used the following as the On Format event of the report's Detail section:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.ImageControl.Picture = Me.ImageLocation.Value
End Sub
When I print the report I see the images associated with the filenames in the table.
Edit re: comment
Newer versions of Access (since at least Access 2010) do not need the On Format VBA code. We can simply place an Image control on the report and set its Control Source property to the (text) field containing the path to the image file. Thanks to Albert D. Kallal for the tip!

Exporting BIRT report into CSV

I am Using BIRT for reporting in my project.
The report shows correct value for amount(String) as 123456789123, but when i try to export the same report into csv, the csv file shows same amount as 1.234E11.
I want to value as 123456789123 in csv too.
Please help
Thanks
I imagine this is probably an issue with viewing it in Excel. Exporting data does not export format codes. Open the csv in notepad and you will see the correct data. If you export the report to excel you can set a custom format code like #####0 in the Format Number property in the properties editor for the data item.
If the number is too large excel will display the value like that. If you expand the column and set the column to number under format cells it will display correctly. You will need to save it as an excel workbook.
We just had this problem with the our BiRT reporting tool. When we opened the exported file in a text editor the number was formatted in scientific notation. This was a bug with one of Birt's custom formatters.
We had to look at org.eclipse.birt.report.engine.dataextraction.impl.CommonDataExtractionImpl and change the line
valueFormatters[i] = new NumberFormatter( patterns[i], this.locale );
to
String pattern = patterns[i] == null ? "Unformatted" : patterns[i];
valueFormatters[i] = new NumberFormatter( pattern, this.locale );
Setting the pattern to "Unformatted" made default format stay as a normal integer rather than scientific notation (via a decimal formatter).