[ gorancho @ 16.07.2009. 11:22 ] @
Želeo bi da sačuvam riport u nekom polju. Izvor podataka se menja svremena na vreme a želim da čuvam "original" izveštaj ako je još moguće bez *.snp verzije |
[ gorancho @ 16.07.2009. 11:22 ] @
[ pmiroslav @ 16.07.2009. 11:31 ] @
Probaj podatke iz tablice ili querya na temelju kojih praviš izvještaj kopirati u neku novu tablicu i dodati im datum ili ime i tako ih čuvati.
Onda iz te tablice možeš ponovno izabrati za štampu izjveštaj koji ti treba. [ Zidar @ 16.07.2009. 13:57 ] @
Reporti su dinamicki po prirodi. STa u tom momentu imas u source tabelama, to ce report prikazati. Miroslav ti je dao dobru ideju, koja se u sustini svodi na arhiviranje podataka koje vise ences menjati.
Postoje i drugi nacini. Mozes da recimo izvestaj sacuvas kao PDF fajl, pa onda taj PDF sacuvas u bazi u OLE polju (ili cuvas samo putanju, a PDF sedi u nekom folderu gde samo specijalni korisnici iamju Write/Update/Delelte prava a svi ostali Read Only (ili ni to). Ako je izvestaj jednostvan, bez grafike, linija i slicno, mozda mozes da napravis text fajl koji izgleda otprilike kao izvestaj pa da to cuvas negde, u bazi ili na disku. Ima jos, ali se sve vrti oko istog - snapshot ili podataka ili samog reporta. Svi ovi nacini zahtevaju vise rada nego ono sto ti je Miroslav predlozio. Ne postoji recept, zavisno od tvoje situacije, uradi kako ti Misroslav predlaze, ili izaberi neki od opisanih nacina ili smisli nesto sam. :-) [ gorancho @ 16.07.2009. 15:41 ] @
Lenjost je ponekad seme napredka!!!
Ovaj izveštaj ima i svoje podizveštaje, nekad jedan a nekada više i dodajem i neke literale koji su u zavisnosti od moje/klijentove inspiracije. Varijanta koju tražim je samo da bi izbegao možda par sati razvijanja dodatnog modela objekata i veza paralelno sa postojećim pa rekoh da skratim. Elem, probao sam interaktivno da uvezem Izvestaj.snp u polje koje je ole-formata i to je o.k. ali kako da to odradim kroz kod ??? [ pmiroslav @ 16.07.2009. 19:19 ] @
Točno je da ako u izvještaju imaš podizvještaje onda je to malo komplicirano čuvati u jednoj tablici kako sam ja to predložio. Ali možda je kako kaže Zidar riješenje PDF file. Ako ti to odgovara, evo ja sam našao CODE koji će ti možda pomoći.
VBA code that successfully converts an Access report to a PDF file. Instructions: Copy everything below the line into a module in an Access database. To use the code on Access 2000 and earlier, it is necessary to comment out three lines referring to the printer object and set the report to use PDF995 in the report page layout dialog. The only way to change the printer for a report in these previous versions is to open the report in design mode and make the change, re-save the report, and then run it. To create your pdf file, call the function pdfwrite "report name","report filter(may be "")","Path to put the pdf" A new pdf file named with the name of the report will be created. ------------------------------------------------------ Code: Option Compare Database Option Explicit 'Read INI settings Declare Function GetPrivateProfileString Lib "kernel32" Alias _ "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _ ByVal lpKeyName As Any, ByVal lpDefault As String, _ ByVal lpReturnedString As String, ByVal nSize As Long, _ ByVal lpFileName As String) As Long 'Write settings Declare Function WritePrivateProfileString Lib "kernel32" Alias _ "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _ ByVal lpKeyName As Any, ByVal lpString As Any, _ ByVal lpFileName As String) As Long Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub pdfwrite(reportname As String, destpath As String, Optional strcriteria As String) ' Runs an Access report to PDF995 to create a pdf file from the report. ' Input parameters are the name of the report within the current database, ' the path for the output file, and an optional criteria for the report ' Be sure to check that the "Generating PDF CS" setting in pdfsync.ini is set to 0 ' when pdf995 is idle. This codes uses that as a completion flag as it seems to be ' the most reliable indication that PDF995 is done writing the pdf file. ' Note: The application.printer object is not valid in Access 2000 ' and earlier. In that case, set the printer in the report to pdf995 ' and comment out the references herein to the application.printer Dim syncfile As String, maxwaittime As Long Dim iniFileName As String, tmpPrinter As Printer Dim outputfile As String, x As Long Dim tmpoutputfile As String, tmpAutoLaunch As String ' set the location of the PDF995.ini and the pdfsync files iniFileName = "c:\pdf995\res\pdf995.ini" syncfile = "c:\documents and settings\all users\application data\pdf995\res\pdfsync.ini" ' build the output file name from the path parameter and the report name If Mid(destpath, Len(destpath), 1) <> "\" Then destpath = destpath & "\" outputfile = destpath & reportname & ".pdf" ' PDF995 operates asynchronously. We need to determine when it is done so we can ' continue. This is done by creating a file and having PDF995 delete it using the ' ProcessPDF parameter in its ini file which runs a command when it is complete. ' save current settings from the PDF995.ini file tmpoutputfile = ReadINIfile("PARAMETERS", "Output File", iniFileName) tmpAutoLaunch = ReadINIfile("PARAMETERS", "Autolaunch", iniFileName) ' remove previous pdf if it exists On Error Resume Next Kill outputfile On Error GoTo Cleanup ' setup new values in PDF995.ini x = WritePrivateProfileString("PARAMETERS", "Output File", outputfile, iniFileName) x = WritePrivateProfileString("PARAMETERS", "AutoLaunch", "0", iniFileName) ' change the default printer to PDF995 ' if running on Access 2000 or earlier, comment out the next two lines Set tmpPrinter = Application.Printer Application.Printer = Application.Printers("PDF995") 'print the report DoCmd.OpenReport reportname, acViewNormal, , strcriteria ' cleanup delay to allow PDF995 to finish up. When flagfile is nolonger present, PDF995 is done. Sleep (10000) maxwaittime = 300000 'If pdf995 isn't done in 5 min, quit anyway Do While ReadINIfile("PARAMETERS", "Generating PDF CS", syncfile) = "1" And maxwaittime > 0 Sleep (10000) maxwaittime = maxwaittime - 10000 Loop ' restore the original default printer and the PDF995.ini settings Cleanup: Sleep (10000) x = WritePrivateProfileString("PARAMETERS", "Output File", tmpoutputfile, iniFileName) x = WritePrivateProfileString("PARAMETERS", "AutoLaunch", tmpAutoLaunch, iniFileName) x = WritePrivateProfileString("PARAMETERS", "Launch", "", iniFileName) On Error Resume Next ' if running on Access 2000 or earlier, comment out the next line Application.Printer = tmpPrinter End Sub Function ReadINIfile(sSection As String, sEntry As String, sFilename As String) As String Dim x As Long Dim sDefault As String Dim sRetBuf As String, iLenBuf As Integer Dim sValue As String 'Six arguments 'Explanation of arguments: 'sSection: ini file section (always between brackets) 'sEntry : word on left side of "=" sign 'sDefault$: value returned if function is unsuccessful 'sRetBuf$ : the value you're looking for will be copied to this buffer string 'iLenBuf% : Length in characters of the buffer string 'sFileName: Path to the ini file sDefault$ = "" sRetBuf$ = String$(256, 0) '256 null characters iLenBuf% = Len(sRetBuf$) x = GetPrivateProfileString(sSection, sEntry, _ sDefault$, sRetBuf$, iLenBuf%, sFilename) ReadINIfile = Left$(sRetBuf$, x) End Function [ gorancho @ 16.07.2009. 19:58 ] @
[ Zidar @ 16.07.2009. 20:13 ] @
Postupak ima dva koraka:
1) kreirati PDF isli snapshot file 2) ubaciti file sa diska u OLE polje u tabele Na prvo ne mogu da dam odgovor, svako ima svoj nacin. Ja koristim alat koji se kupuje da pravim PDF,a li ima i besplatnih, a moze i Adobe da posluzi. Trtko je mislim dao lep primer pre neki dan, potrazi. Za 2) evo sta kaze Microsoft: http://support.microsoft.com/kb/205635 Svodi se na 4 linije koda: Data1.Recordset.AddNew OLE1.CreateEmbed "C:\Windows\Circles.bmp" ' Assume the bitmap file is located at C:\Windows\ folder. Data1.Recordset.Update Data1.Recordset.MoveLast Sad, path je hard-kodiran, "C:\Windows\Circles.bmp". Dobar porgramer ce da upotrebi neku varijantu FileOpen dialog boxa, umesto hard kodiranaj. Hard kodiranje moze da prodje,a ko c euvek u koraku 1) fajl da se kreira sa istim imenom na istoj lokaciji. ![]() [ Zidar @ 16.07.2009. 22:02 ] @
OOPS, onaj kod iz prethodne poruke bio je za VB. Evo primer za Access, kako se PDF fajl 'pomocu dugmeta' ubacuje u atbelu (ili se linkuje, ko voli vise tako)
Kako u PSDF? Upravo sam otkrio da moj Access 2007 ima opciju da posalje report u PDF. ne znam kako to uraditi iz koda, ali kad kliken Print, imamopciju PUblich as PDF ili tako nesto. Posle samo izaberet taj fajl.... :-) [ Getsbi @ 17.07.2009. 06:28 ] @
I Access 2003 ima opciju slanja izveštaja u .pdf.
Dok je je fajl u Print Preview, pokrenete File, Send To, Mail Recipient As Adobe PDF. Krenete da napravite Attachment (odaberete lokaciju na disku), a onda kad Access ponudi, odustanete od slanja emaila. PDF fajl se nalazi na lokaciji vašeg diska. Preko koda nisam ubacivao .pdf fajl u tabelu, ali ako otvorite tabelu sa OLE Object poljem, kliknete na novi zapis tog polja desnim tasterom miša, Access će ponuditi opciju Insert Object. Ostalo je stvar rutine. Opcija Adobe Acrobat Document je prva u listi. Izaberete Create from File i putanju do vašeg fajla pomoću Browse. Ovo mi se čini relativno pristojnim načinom za čuvanje reporta u nekom polju. Verovatno da putem VBA koda može i da se automatizuje. [ Catch 22 @ 17.07.2009. 10:39 ] @
Citat: Zidar: ... Upravo sam otkrio da moj Access 2007 ima opciju da posalje report u PDF. ne znam kako to uraditi iz koda, ali kad kliken Print, imamopciju PUblich as PDF ili tako nesto. Posle samo izaberet taj fajl.... To smo već konstatovali kao jednu od značajnijih novina Service pack 2 za MS Office, nakon čije instalacije se ista ta opcija pojavljuje i u Excelu, Wordu... ![]() Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|