Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old May 11th, 2008, 08:06 PM
joao.aav joao.aav is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 joao.aav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 34 sec
Reputation Power: 0
Unhappy Reports - Snapshot error

I'm with a problem with an Access Project that I can't fix no matter what I do.I already tried to find the solution in every place on Internet and I can't fix this.

This is the error
I have an 2003-access project with several pages of reports. Those pages of reports has several charts and data.. I need to export these data to PDF, and the solution was to export first snapshot and then on top of the snapshot file export to PDF.
So far so good, could already do all that. But the problem is, when the access generates this snapshot file, at about 40% of the time it generates information that does not exist in graphics. The graphics bring data from tables based on querys, and I already performed these querys thousands of times and the data are correct. The most strange is that after having created the snapshot, I can only ask to regenerate that the error will not appear.
Briefly, the error happens when I road the process that generates the snapshots via VBA, with each case in an hour (or more) page and not always happen.

I am almost giving up the concert this problem !!!
already updated version of the office for the service pack 3, created a new database, exported the pages separately, among other things.

someone went through this problem?
if someone can I help you, thank you very much

Reply With Quote
  #2  
Old May 11th, 2008, 09:06 PM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
Click here for more information
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,454 sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)  Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Weeks 5 Days 13 h 42 m 29 sec
Reputation Power: 1091
I export reports to pdf on a weekly basis. The way I do it is print to pdf, which of course requires the full version of acrobat.... in my case version 7. Albeit, I email it, which means I right click on the report and send to email recipient as pdf. It saves it as pdf first, meaning, I don't have to email it, but in my case I do.

Basically, I have a very sofisticated time card program that depends on a few queries. I run my report off the final query and then in preview, I right click and send email as pdf.

I am not at work right now, but tomorrow, I can look into bypassing exporting as a snapshot first. Like I said, I'm not at work, but I think I remember seeing an option as printing to pdf. The send email as pdf works for me, and if needed, I don't have to send the email and the pdf will be saved before the email is opened, meaning, if I cancel the email, the pdf will still be there.
__________________
Did I help you? If so gimme rep by clicking on the at the top right corner of this post

Madness does not always howl. Sometimes, it is the quiet voice at the end of the day saying, "Hey, is there room in your head for one more?"

Reply With Quote
  #3  
Old May 11th, 2008, 09:14 PM
joao.aav joao.aav is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 joao.aav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 34 sec
Reputation Power: 0
what I need is to create a pdf file from a report through vba.
The problem is not in the send mail as like in the creation of snapshot. The problem is that when I create the snapshot, it comes with data that are not in the database
If you have any sugestion, please say it, and thanks for the advice anyway.

Reply With Quote
  #4  
Old May 11th, 2008, 11:54 PM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
Click here for more information
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,454 sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)  Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1Folding Points: 189478 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Weeks 5 Days 13 h 42 m 29 sec
Reputation Power: 1091
well, I hate to say, the method you use is very unique. I will see tomorrow if I can duplicate it, as I don't have the full version of adobe at home. That is, if I find the time, as my IT duties come first.

Can you give us the vba you are using to create the "snapshot"? It's a little confusing on what you are doing here.

Lastly, remember, these are free forums; while most of us are experts here, that doesn't mean we've done the same things you have. Generally speaking, we go by what is posted. It is important that you go into as much detail as is allowed and include any code you are using. We are not mind readers, nor do we usually know what code you are working with.

To be honest, had you posted your vba, I would probably have given a totally different answer.

Please don't chastise those who are willing to help you for free.

That would be like me saying, I have this database that imports all file names via vba.....why does it import it wrong when it worked before? I could even tell you that I import through a dos function which saves it to text, and ask you why it imports wrong....

It's important to be precise and include your functions you are using.

Reply With Quote
  #5  
Old May 12th, 2008, 11:52 AM
joao.aav joao.aav is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 joao.aav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 34 sec
Reputation Power: 0
Hello, here it goes my vba code used to export to snapshot

Public Function ExportSnp(txtReport As String, nm_diretoria As String, ctl As Control) As Boolean
Dim FormatoExp As String
Dim SoloUnError As Boolean

FormatoExp = "Snapshot Format(*.snp)"
Arq = "\Snapshots\" & nm_diretoria & ".snp"

Application.Echo False

On Error GoTo errorXP
'exportamos
DoCmd.OutputTo acOutputReport, txtReport, _
FormatoExp, CurrentProjectPath & Arq

'Joga em um objeto controle snapshot view caso necessite visualização na tela
ctl.SnapshotPath = CurrentProjectPath & Arq
Application.Echo True

Exit Function

errorXP:

If Err.Number = 2282 And SoloUnError = False Then
FormatoExp = "Formato Snapshot(*.snp)"
SoloUnError = True
Resume
Else
MsgBox Err.Description
End If
End Function


and here is my code to generate PDF


Option Compare Database
Option Explicit

'Name: ConvertReportToPDF
'
'Version: 7.51
'
'Purpose:
'
'*1) Export report to Snapshot and then to PDF. Output exact duplicate of a Report to PDF.
'
'************************************************* *
'
'
'Dependencies: DynaPDF.dll StrStorage.dll clsCommonDialog
'
'Inputs: See inline Comments for explanation

'Output: See inline Comments for explanation
'
'Credits: Anyone who wants some!
'
'BUGS: Please report any bugs to my email address.
'
'What's Missing:
' Enhanced Error Handling
'
'How it Works:
' A SnapShot file is created in the normal manner by code like:
' 'Export the selected Report to SnapShot format
' DoCmd.OutputTo acOutputReport, rptName, "SnapshotFormat(*.snp)", _
' strPathandFileName
'
' rptName is the desired Report we are working with.
' strPathandFileName can be anything, in this Class it is a
' Temporary FileName and Path created with calls to the
' GetTempPath and GetUniqueFileName API's.
'
' We then pass the FileName to the SetupDecompressOrCopyFile API.
' This will decompress the original SnapShot file into a
' Temporary file with the same name but a "tmp" extension.
'
' The decompressed Temp SnapShot file is then passed to the
' ConvertUncompressedSnapshotToPDF function exposed by the StrStorage DLL.
' The declaration for this call is at the top of this module.
' The function uses the Structured Storage API's to
' open and read the uncompressed Snapshot file. Within this file,
' there is one Enhanced Metafile for each page of the original report.
' Additionally, there is a Header section that contains, among other things,
' a copy of the Report's Printer Devmode structure. We need this to
' determine the page size of the report.

'The StrStorage DLL exposes one function.
'Public Function ConvertUncompressedSnapshotToPDF( _
'UnCompressedSnapShotName As String, _
'OutputPDFname As String = "", _
'Optional CompressionLevel As Long = 0, _
'Optional PasswordOwner As String = "" _
'Optional PasswordOpenAs String = "" _
'Optional PasswordRestrictions as Long = 0, _
'Optional PDFNoFontEmbedding As Long = 0 _
') As Boolean

' Now we call the ConvertUncompressedSnapshotToPDF funtion exposed by the StrStorage DLL.
'
'blRet = ConvertUncompressedSnapshot(sFileName as String, sPDFFileName as String)
'
'
'Have Fun!
'
'
'
' ************************************************** ****



Public Declare Function ConvertUncompressedSnapshot Lib "StrStorage.dll" _
(ByVal UnCompressedSnapShotName As String, _
ByVal OutputPDFname As String, _
Optional ByVal CompressionLevel As Long = 0, _
Optional ByVal PasswordOwner As String = "", _
Optional ByVal PasswordOpen As String = "", _
Optional ByVal PasswordRestrictions As Long = 0, _
Optional PDFNoFontEmbedding As Long = 0 _
) As Boolean

' For debugging with Visual C++
'Lib "C:\VisualCsource\Debug\StrStorage.dll"

Private Declare Function ShellExecuteA Lib "shell32.dll" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Declare Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long

Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long

Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long

Private Declare Function GetTempFileName _
Lib "kernel32" Alias "GetTempFileNameA" _
(ByVal lpszPath As String, _
ByVal lpPrefixString As String, _
ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long

Private Declare Function SetupDecompressOrCopyFile _
Lib "setupAPI" _
Alias "SetupDecompressOrCopyFileA" ( _
ByVal SourceFileName As String, _
ByVal TargetFileName As String, _
ByVal CompressionType As Integer) As Long

Private Declare Function SetupGetFileCompressionInfo _
Lib "setupAPI" _
Alias "SetupGetFileCompressionInfoA" ( _
ByVal SourceFileName As String, _
TargetFileName As String, _
SourceFileSize As Long, _
DestinationFileSize As Long, _
CompressionType As Integer _
) As Long


'Compression types
Private Const FILE_COMPRESSION_NONE = 0
Private Const FILE_COMPRESSION_WINLZA = 1
Private Const FILE_COMPRESSION_MSZIP = 2

Private Const Pathlen = 256
Private Const MaxPath = 256


' Allow user to set FileName instead
' of using API Temp Filename or
' popping File Dialog Window
Private mSaveFileName As String

' Full path and name of uncompressed SnapShot file
Private mUncompressedSnapFile As String

' Name of the Report we ' working with
Private mReportName As String

' Instance returned from LoadLibrary calls
Private hLibDynaPDF As Long
Private hLibStrStorage As Long


Public Function ConvertReportToPDF( _
Optional RptName As String = "", _
Optional SnapshotName As String = "", _
Optional OutputPDFname As String = "", _
Optional ShowSaveFileDialog As Boolean = False, _
Optional StartPDFViewer As Boolean = True, _
Optional CompressionLevel As Long = 0, _
Optional PasswordOwner As String = "", _
Optional PasswordOpen As String = "", _
Optional PasswordRestrictions As Long = 0, _
Optional PDFNoFontEmbedding As Long = 0 _
) As Boolean


' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to display
' the standard windows File Dialog window to select an exisiting Snapshot file
' CompressionLevel - not hooked up yet
' PasswordOwner - not hooked up yet
' PasswordOpen - not hooked up yet
' PasswordRestrictions - not hooked up yet
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only




Dim s As String
Dim blRet As Boolean
' Let's see if the DynaPDF.DLL is available.
blRet = LoadLib()
If blRet = False Then
' Cannot find DynaPDF.dll or StrStorage.dll file
Exit Function
End If

On Error GoTo ERR_CREATSNAP

Dim strPath As String
Dim strPathandFileName As String
Dim strEMFUncompressed As String

Dim sOutFile As String
Dim lngRet As Long

' Init our string buffer
strPath = Space(Pathlen)

'Save the ReportName to a local var
mReportName = RptName

' Let's kill any existing Temp SnapShot file
If Len(mUncompressedSnapFile & vbNullString) > 0 Then
Kill mUncompressedSnapFile
mUncompressedSnapFile = ""
End If

' If we have been passed the name of a Snapshot file then
' skip the Snapshot creation process below
If Len(SnapshotName & vbNullString) = 0 Then

' Make sure we were passed a ReportName
If Len(RptName & vbNullString) = 0 Then
' No valid parameters - FAIL AND EXIT!!
ConvertReportToPDF = ""
Exit Function
End If

' Get the Systems Temp path
' Returns Length of path(num characters in path)
lngRet = GetTempPath(Pathlen, strPath)
' Chop off NULLS and trailing "\"
strPath = Left(strPath, lngRet) & Chr(0)

' Now need a unique Filename
' locked from a previous aborted attemp.
' Needs more work!
'comentado para gerar na raiz do sistema
'strPathandFileName = GetUniqueFilename(strPath, "SNP" & Chr(0), "snp")
strPathandFileName = CurrentProjectPath & Arq

' Export the selected Report to SnapShot format
'DoCmd.OutputTo acOutputReport, RptName, "SnapshotFormat(*.snp)", strPathandFileName

' Make sure the process has time to complete
DoEvents

Else
strPathandFileName = SnapshotName

End If

' Let's decompress into same filename but change type to ".tmp"
'strEMFUncompressed = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
'strEMFUncompressed = strEMFUncompressed & "tmp"
Dim sPath As String * 512
lngRet = GetTempPath(512, sPath)

'comentado para gerar na raiz do sistema
'strEMFUncompressed = GetUniqueFilename(sPath, "SNP", "tmp")
strEMFUncompressed = GetUniqueFilename(CurrentProjectPath, "SNP", "tmp")

lngRet = SetupDecompressOrCopyFile(strPathandFileName, strEMFUncompressed, 0&)

If lngRet <> 0 Then
Err.Raise vbObjectError + 525, "ConvertReportToPDF.SetupDecompressOrCopyFile", _
"Sorry...cannot Decompress SnapShot File" & vbCrLf & _
"Please select a different Report to Export"
End If

' Set our uncompressed SnapShot file name var
mUncompressedSnapFile = strEMFUncompressed

' Remember to Cleanup our Temp SnapShot File if we were NOT passed the
' Snapshot file as the optional param
'Não apaga mais o arquivo snp
'If Len(SnapshotName & vbNullString) = 0 Then
'Kill strPathandFileName
'End If


' Do we name output file the same as the input file name
' and simply change the file extension to .PDF or
' do we show the File Save Dialog
If ShowSaveFileDialog = False Then

' let's decompress into same filename but change type to ".tmp"
' But first let's see if we were passed an output PDF file name
If Len(OutputPDFname & vbNullString) = 0 Then
sOutFile = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
sOutFile = sOutFile & "PDF"
Else
sOutFile = OutputPDFname
End If

'mudado
sOutFile = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
sOutFile = sOutFile & "PDF"
Else
' Call File Save Dialog
sOutFile = fFileDialog()
If Len(sOutFile & vbNullString) = 0 Then
Exit Function
End If

End If

' Call our function in the StrStorage DLL
' Note the Compression and Password params are not hooked up yet.
blRet = ConvertUncompressedSnapshot(mUncompressedSnapFile, sOutFile, _
CompressionLevel, PasswordOwner, PasswordOpen, PasswordRestrictions, PDFNoFontEmbedding)

If blRet = False Then
Err.Raise vbObjectError + 526, "ConvertReportToPDF.ConvertUncompressedSnaphot", _
"Sorry...damaged SnapShot File" & vbCrLf & _
"Please select a different Report to Export"
End If

' Do we open new PDF in registered PDF viewer on this system?
'abre o pdf - não necessário no ABN Book
'If StartPDFViewer = True Then
'ShellExecuteA Application.hWndAccessApp, "open", sOutFile, vbNullString, vbNullString, 1
'End If

' Success
ConvertReportToPDF = True


EXIT_CREATESNAP:

' Let's kill any existing Temp SnapShot file
'If Len(mUncompressedSnapFile & vbNullString) > 0 Then
On Error Resume Next
Kill mUncompressedSnapFile
mUncompressedSnapFile = ""
'End If

' If we aready loaded then free the library
If hLibStrStorage <> 0 Then
hLibStrStorage = FreeLibrary(hLibStrStorage)
End If

If hLibDynaPDF <> 0 Then
hLibDynaPDF = FreeLibrary(hLibDynaPDF)
End If

Exit Function

ERR_CREATSNAP:
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
mUncompressedSnapFile = ""
ConvertReportToPDF = False
Resume EXIT_CREATESNAP

End Function

Private Function LoadLib() As Boolean
Dim s As String
Dim blRet As Boolean

On Error Resume Next

LoadLib = False

' If we aready loaded then free the library
If hLibDynaPDF <> 0 Then
hLibDynaPDF = FreeLibrary(hLibDynaPDF)
End If


' Our error string
s = "Sorry...cannot find the DynaPDF.dll file" & vbCrLf
s = s & "Please copy the DynaPDF.dll file to your Windows System32 folder or into the same folder as this Access MDB."

' OK Try to load the DLL assuming it is in the Window System folder
hLibDynaPDF = LoadLibrary("DynaPDF.dll")
If hLibDynaPDF = 0 Then
' See if the DLL is in the same folder as this MDB
' CurrentDB works with both A97 and A2K or higher
hLibDynaPDF = LoadLibrary(CurrentDBDir() & "DynaPDF.dll")
If hLibDynaPDF = 0 Then
MsgBox s, vbOKOnly, "MISSING DynaPDF.dll FILE"
LoadLib = False
Exit Function
End If
End If


' Our error string
s = "Sorry...cannot find the StrStorage.dll file" & vbCrLf
s = s & "Please copy the StrStorage.dll file to your Windows System32 folder or into the same folder as this Access MDB."

' ** Commented out for Debugging only - Must be active
' ************************************************** *************************
'
' OK Try to load the DLL assuming it is in the Window System folder
hLibStrStorage = LoadLibrary("StrStorage.dll")
If hLibStrStorage = 0 Then
' See if the DLL is in the same folder as this MDB
' CurrentDB works with both A97 and A2K or higher
hLibStrStorage = LoadLibrary(CurrentDBDir() & "StrStorage.dll")
If hLibStrStorage = 0 Then
MsgBox s, vbOKOnly, "MISSING StrStorage.dll FILE"
Exit Function
End If
End If


' RETURN SUCCESS
LoadLib = True
End Function


'******************** Code Begin ****************
'Code courtesy of
'Terry Kreft & Ken Getz
'
Private Function CurrentDBDir() As String
Dim strDBPath As String
Dim strDBFile As String
strDBPath = CurrentDb.name
strDBFile = Dir(strDBPath)
CurrentDBDir = Left$(strDBPath, Len(strDBPath) - Len(strDBFile))
End Function
'******************** Code End ****************



Private Function GetUniqueFilename(Optional path As String = "", _
Optional Prefix As String = "", _
Optional UseExtension As String = "") _
As String

' originally Posted by Terry Kreft
' to: comp.Databases.ms -Access
' Subject: Re: Creating Unique filename ??? (Dev code)
' Date: 01/15/2000
' Author: Terry Kreft <terry.kreft@mps.co.uk>

' SL Note: Input strings must be NULL terminated.
' Here it is done by the calling function.

Dim wUnique As Long
Dim lpTempFileName As String
Dim lngRet As Long

wUnique = 0
If path = "" Then path = CurDir
lpTempFileName = String(MaxPath, 0)
lngRet = GetTempFileName(path, Prefix, _
wUnique, lpTempFileName)

lpTempFileName = Left(lpTempFileName, _
InStr(lpTempFileName, Chr(0)) - 1)
Call Kill(lpTempFileName)
If Len(UseExtension) > 0 Then
lpTempFileName = Left(lpTempFileName, Len(lpTempFileName) - 3) & UseExtension
End If
GetUniqueFilename = lpTempFileName
End Function


Private Function fFileDialog() As String
' Calls the API File Save Dialog Window
' Returns full path to new File

On Error GoTo Err_fFileDialog

' Call the File Common Dialog Window
Dim clsDialog As Object
Dim strTemp As String
Dim strFname As String

Set clsDialog = New clsCommonDialog

' Fill in our structure
' I'll leave in how to select Gif and Jpeg to
' show you how to build the Filter in case you want
' to use this code in another project.
clsDialog.Filter = "PDF (*.PDF)" & Chr$(0) & "*.PDF" & Chr$(0)
'clsDialog.Filter = clsDialog.Filter & "Gif (*.GIF)" & Chr$(0) & "*.GIF" & Chr$(0)
'clsDialog.Filter = "ALL (*.*)" & Chr$(0) & "*.*" & Chr$(0)
clsDialog.hDC = 0
clsDialog.MaxFileSize = 256
clsDialog.Max = 256
clsDialog.FileTitle = vbNullString
clsDialog.DialogTitle = "Please Select a path and Enter a Name for the PDF File"
clsDialog.InitDir = vbNullString
clsDialog.DefaultExt = vbNullString

' Display the File Dialog
clsDialog.ShowSave

' See if user clicked Cancel or even selected
' the very same file already selected
strFname = clsDialog.FileName
'If Len(strFname & vbNullString) = 0 Then
' Raise the exception
' Err.Raise vbObjectError + 513, "clsPrintToFit.fFileDialog", _
'"Please type in a Name for a New File"
'End If

' Return File Path and Name
fFileDialog = strFname

Exit_fFileDialog:

Err.Clear
Set clsDialog = Nothing
Exit Function

Err_fFileDialog:
fFileDialog = ""
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
Resume Exit_fFileDialog

End Function




Public Function fFileDialogSnapshot() As String
' Calls the API File Open Dialog Window
' Returns full path to existing Snapshot File

On Error GoTo Err_fFileDialog

' Call the File Common Dialog Window
Dim clsDialog As Object
Dim strTemp As String
Dim strFname As String

Set clsDialog = New clsCommonDialog

' Fill in our structure
' I'll leave in how to select Gif and Jpeg to
' show you how to build the Filter in case you want
' to use this code in another project.
clsDialog.Filter = "SNAPSHOT (*.SNP)" & Chr$(0) & "*.SNP" & Chr$(0)
'clsDialog.Filter = "ALL (*.*)" & Chr$(0) & "*.*" & Chr$(0)
clsDialog.hDC = 0
clsDialog.MaxFileSize = 256
clsDialog.Max = 256
clsDialog.FileTitle = vbNullString
clsDialog.DialogTitle = "Please Select a Snapshot File"
clsDialog.InitDir = vbNullString
clsDialog.DefaultExt = vbNullString

' Display the File Dialog
clsDialog.ShowOpen

' See if user clicked Cancel or even selected
' the very same file already selected
strFname = clsDialog.FileName
If Len(strFname & vbNullString) = 0 Then
' Do nothing. Add your desired error logic here.
End If

' Return File Path and Name
fFileDialogSnapshot = strFname

Exit_fFileDialog:

Err.Clear
Set clsDialog = Nothing
Exit Function

Err_fFileDialog:
fFileDialogSnapshot = ""
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
Resume Exit_fFileDialog

End Function



Public Function fFileDialogSavePDFname() As String
' Calls the API File Open Dialog Window
' Returns full path to existing Snapshot File

On Error GoTo Err_fFileDialog

' Call the File Common Dialog Window
Dim clsDialog As Object
Dim strTemp As String
Dim strFname As String

Set clsDialog = New clsCommonDialog

' Fill in our structure
' I'll leave in how to select Gif and Jpeg to
' show you how to build the Filter in case you want
' to use this code in another project.
clsDialog.Filter = "PDF (*.PDF)" & Chr$(0) & "*.PDF" & Chr$(0)
'clsDialog.Filter = "ALL (*.*)" & Chr$(0) & "*.*" & Chr$(0)
clsDialog.hDC = 0
clsDialog.MaxFileSize = 256
clsDialog.Max = 256
clsDialog.FileTitle = vbNullString
clsDialog.DialogTitle = "Please Select a name for the PDF File"
clsDialog.InitDir = vbNullString
clsDialog.DefaultExt = vbNullString



' Display the File Dialog
clsDialog.ShowOpen

' See if user clicked Cancel or even selected
' the very same file already selected
strFname = clsDialog.FileName
If Len(strFname & vbNullString) = 0 Then
' Do nothing. Add your desired error logic here.
End If

' Return File Path and Name
fFileDialogSavePDFname = strFname

Exit_fFileDialog:

Err.Clear
Set clsDialog = Nothing
Exit Function

Err_fFileDialog:
fFileDialogSavePDFname = ""
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
Resume Exit_fFileDialog

End Function




My problem isn't in the cration of the pdf file, because he creates an identical copy of the snapshot file. My problem is in the own acesse's reports or in the creation of the snapshot( this I can't identify properly yet ). Imagine in a page of reports divided in 4 shares, where each share have a graphic. When I run my processes, the system prints the same reports many times, for different areas of my company. What happens wrong is that some boards, sometimes ( I didn't see the error periodicity ), come with data that aren't on the tables ( from where the graphics bring the data ), not even in querys and in any place. Simply, arise information that doesnt exist in my MDB file and they appear on graphics. The most strange is that if I simply run the process again, those data appear correctly where were wrong and sometimes appear another wrong data in other graphics that were right previously.

I hope to have explained better my problem.

One more time,hanks for the help

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Reports - Snapshot error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway