Can you save a report

B

Bob

I have an Invoice/Statement db is it possible for access to save a Report
when I produce it for printing . Like holding them to view later??...Thanks
Bob







..........Jenny Vance
 
G

Guest

Yes, you can save a report as a 'snapshot' (or
as an office writer document)

But no, that is a separate file. You can't save the
report inside the database, and you need to use
the snapshot viewer (or office document viewer)
to view it later.

(david)
 
B

Bob

So is it possible to add to my code to save a copy in (C:Holding Statements)
every time I go to print a statement?
And how would they be saved under what name?...Thanks for your help..Bob
 
J

JK

Hi Bob

The syntax is:

DoCmd.OutputTo acOutputReport, "Your report Name", acFormatRTF,
"YourFileName.RTF", True

This will save the file In RTF format
True at the end will open the file, false will not
It will overwrite existing file with the same name *without a warning*

Regards/JK
 
B

Bob

Where would I enter the syntax and where do I find the file name xxxxx.RTF
.....Thanks Bob
 
J

JK

Bob,

Enter the syntax anywhere in the database - eg. create a Command Button and
use the On Click event:

Private Sub YourButton_Click()

DoCmd.OutputTo acOutputReport, "Your report Name", _
acFormatRTF, "YourFileName.RTF", True

End Sub

Alternatively you can add it after the printing statements command

++++++

XXXXXX.RTF if the name you give to file you output to, including the path:

"C:\Access\Holding Statements\October06.RTF"
(including the quotation marks)

you may want to prompt for file name before the output:

Private Sub YourButton_Click()

Dim StrFileName as string

'---- get the file name
strFileName = InputBox("Enter File Name And Path Incl Extension:")

'--- Test for empty file name
If Len(strFileName)=0 then
MsgBox "No name Entered"
Exit Sub
End If

DoCmd.OutputTo acOutputReport, "Your report Name", _
acFormatRTF, strFileName,True

End Sub

I have a similar code, slightly more complex (more checks/tests) I can
modify if you wand something more robust

Regards/JK
 
B

Bob

Jk, the problem is I select a Client, Date Range then the report is opened
in Preview, Now when I click the print option I would like a copy to go to
C:\Statements
This what is OnClick to show my preview
Statement........................Thanks Bob

Private Sub cmdStatement_Click()

Select Case Me.OpenArgs

Case "OwnerStatement"

If IsNull(cbOwnerName.value) = True Or cbOwnerName.value =
vbNullString Then
MsgBox "Please Select the Owner.", vbApplicationModal +
vbInformation + vbOKOnly
Exit Sub
End If

Me.Visible = False
DoCmd.OpenReport "rptOwnerPaymentMethod", acViewPreview
'DoCmd.Close acForm, Me.Name
Case "MonthlyPaid"

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"MonthlyPaid"
'Report_rptGenericReport.tbTotal.value =
SUM(Report_rptGenericReport.tbAmount)
'DoCmd.Close acForm, Me.Name
'Report_rptGenericReport.tbTotal =
DSum(Report_rptGenericReport.tbAmount, "rptGenericReport")
'Report_rptGenericReport.tbTotal.ControlSource =
"Sum(Report_rptGenericReport.tbAmount)"
DoCmd.Close acForm, Me.Name
Case "OwnerDue"

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"OwnerDue"
DoCmd.Close acForm, Me.Name
Case "OwnerPaymentMethod"

If IsNull(cbOwnerName.value) = True Or cbOwnerName.value =
vbNullString Then
MsgBox "Please Select the Owner.", vbApplicationModal +
vbInformation + vbOKOnly
Exit Sub
End If

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"OwnerPaymentMethod"
DoCmd.Close acForm, Me.Name

Case "PaymentMethod"

Dim nDateDiff As Integer, nSign As Integer
nDateDiff = DateDiff("d", CDate(tbDateFrom.value),
CDate(tbDateTo.value))
nSign = Sgn(nDateDiff)

If nSign = -1 Or nSign = 0 Then
MsgBox "Please Select Date In Proper Range.",
vbApplicationModal + vbExclamation + vbOKOnly
cmdCalenderTo.SetFocus
Exit Sub
End If

Me.Visible = False
DoCmd.OpenReport "rptGenericReport", acViewPreview, , , ,
"PaymentMethod"
DoCmd.Close acForm, Me.Name
Case "PrintInvoiceBatch"
If IsNull(tbDateFrom.value) Or tbDateFrom.value = "" Or
IsNull(tbDateTo.value) Or tbDateTo.value = "" Then
MsgBox "Please Enter the Begining Date and End Date.",
vbApplicationModal + vbInformation + vbOKOnly
Exit Sub
End If
Me.Visible = False
DoCmd.OpenReport "rptInvoiceBatch", acViewPreview, , , ,
"PrintInvoiceBatch"
'DoCmd.Close acForm, Me.Name
Case "PrintStatementBatch"
If IsNull(tbDateFrom.value) Or tbDateFrom.value = "" Or
IsNull(tbDateTo.value) Or tbDateTo.value = "" Then
MsgBox "Please Enter the Begining Date and End Date.",
vbApplicationModal + vbInformation + vbOKOnly
Exit Sub
End If
Me.Visible = False
DoCmd.OpenReport "rptOwnerPaymentMethodBatch", acViewPreview, , , ,
"PrintStatementBatch"
'DoCmd.Close acForm, Me.Name
End Select
'DoCmd.OpenReport "rptInvoiceBatch", acViewPreview, , , ,
"PrintInvoiceBatch"
End Sub
 
J

JK

Bob,
As far as I know you cannot print the report to file when the report is open
in a preview. You can however, install PDF as a printer (you will need a
program for that) and "print" into it, this will generate a PDF file which
you can print, I have not tried it with Access.

Failing that you can modify your sub as below, or on similar lines. You can
of course create another button, attach to it a modified version of your
existing sub and replace the doCmd.OpenReport with DoCmd.Output to.

Here is an example of modifying your sub:


Private Sub cmdStatement_Click()


'************
Dim saveReport As integer, savFileName As String

saveReport = MsgBox("Do you want to save the report to file?", _
vbYesNo + vbQuestion + vbApplicationModal)
'***************

Select Case Me.OpenArgs

Case "OwnerStatement"

If IsNull(cbOwnerName.Value) = True Or _
cbOwnerName.Value = vbNullString Then
MsgBox "Please Select the Owner.", _
vbApplicationModal + vbInformation _
+ vbOKOnly
Exit Sub
End If
'******************
If saveReport = vbYes Then
savFileName = "C:\Statements\" & "rptOwnerPaymentMethos" _
& ".RTF"
DoCmd.OutputTo acOutputReport, "rptOwnerPaymentMethos", _
acFormatRTF, savFileName, False
Exit Sub '??????
End If
'*********************
Me.Visible = False
DoCmd.OpenReport "rptOwnerPaymentMethod", _
acViewPreview
'DoCmd.Close acForm, Me.Name
Case "MonthlyPaid"

Me.Visible = False
'******************
If saveReport = vbYes Then
savFileName = "C:\Statements\" & "rptGenericReport" _
& ".RTF"
DoCmd.OutputTo acOutputReport, "rrptGenericReport", _
acFormatRTF, savFileName, False
Exit Sub '?????
End If
'*********************
DoCmd.OpenReport "rptGenericReport", _
acViewPreview, , , , "MonthlyPaid"

...... etc.

Reminding you that this will *overwrite* exiting file with the same name
*without* warning

Regards/Jacob
 
G

Guest

When the report is open in preview mode you can select
OutPut To, (or Analyse with or some thing else) from the
menu, instead of selecting Print.

Snapshot is generally a better format than RTF, because
RTF sometimes has trouble with memo's, and sometimes
drops digits from numbers.

As an alternative to PDF, Office 2003 includes a special
Office document printer, rather like a fax printer or a pdf
printer, that saves the document as a picture.

(david)
 
J

JK

David,
When the report is open in preview mode you can select
OutPut To, (or Analyse with or some thing else) from the
menu, instead of selecting Print.

Where? I dont' have it (ver 2002)
Snapshot is generally a better format than RTF, because
RTF sometimes has trouble with memo's, and sometimes
drops digits from numbers.

This is an *excellant* idea which would actually also solves another Bob's
problem.

Bob,
Use can your Sub but change OpenReport to OutputTo which will write the
file first, open it and then you can print it throu the File Menu
I'll give you the code in another posting

As an alternative to PDF, Office 2003 includes a special
Office document printer, rather like a fax printer or a pdf
printer, that saves the document as a picture.

With respect, this is incorrect. PDF file is not a picture but you cannot
edit it (it is fully protected), unless you have the Professional version
and even then you first convert it to from pdf to an editable file (e.g.
Word) edit it and convert back to re-protect it.


Regards/JK
 
J

JK

Bob,

Here is the code.

That will save the report in Snapshot format, and will open it in view form,
much like the report preview. when the snapshot is open and it is ok to
print you print the snapshot from the Snapshot Viewer Menu:

File->Print

Here is part of your code modified to do that, the ****** show changes

Private Sub cmdStatement_Click()


'************
Dim saveReport As interder, savFileName As String
'***************

Select Case Me.OpenArgs

Case "OwnerStatement"

If IsNull(cbOwnerName.Value) = True Or _
cbOwnerName.Value = vbNullString Then
MsgBox "Please Select the Owner.", _
vbApplicationModal + vbInformation _
+ vbOKOnly 'added + ( to vbokonlt)
Exit Sub
End If
'******************
savFileName = "C:\Statements\" & "rptOwnerPaymentMethos" _
& ".SNP"
' Me.Visible = False ****now You dont need this *****
DoCmd.OutputTo acOutputReport, "rptOwnerPaymentMethos", _
"Snapshot Format", savFileName, True
'DoCmd.OpenReport "rptOwnerPaymentMethod", ******
Replaced*****
'acViewPreview ********Relaced
'**************************
'DoCmd.Close acForm, Me.Name

Case "MonthlyPaid"

'******************
'Me.Visible = False ******** Not needed
savFileName = "C:\Statements\" & "rptGenericReport" _
& ".SNP"
' Me.Visible = False ****now You dont need this *****
DoCmd.OutputTo acOutputReport, "rptGenericReport", _
"Snapshot Format", savFileName, True
'DoCmd.OpenReport "rptGenericReport", _******* Replaced
'acViewPreview, , , , "MonthlyPaid" ******* Repalce
'**************************************************
'Report_rptGenericReport.tbTotal.value = _
'SUM (Report_rptGenericReport.tbAmount)
'DoCmd.Close acForm, Me.Name

...........
etc

Regards/Jacob
 
B

Bob

Thanks Jacob , couple of typos but got it going, 2 things
Can Snapshot be opened at 100% view
And it is only saving the last statement I open is it possible to save them
uniquely under OwnersName? So if I save the same owner statement again it
will just replace the last one saved
thanks for your help.Bob
 
B

Bob

All so is it possible to have a error message, MsgBox "Statements does not
have a folder in C drive" if it does nor exist..thanks Bob
 
G

Guest

Where? I dont' have it (ver 2002)

In the control bar, do you see a blue W? The W stands
for Word, and the control tip is OfficeLinks? That exports
to RTF.
Or, from the file menu, select SaveAs, and save as RTF or
snapshot.

(david)
 
J

JK

Hi Bob
Bob said:
Thanks Jacob , couple of typos but got it going, 2 things
Can Snapshot be opened at 100% view

It is opened in 100%, but if you want to change it:
Right Clik on the report the Zoom->???%
And it is only saving the last statement I open is it possible to save
them uniquely under OwnersName? So if I save the same owner statement
again it will just replace the last one saved
thanks for your help.Bob

umm...
I can give you a routine to aout-number the reports e.g.
OwnerPaymentMethos1, OwnerPaymentMethos2 etc. (or a combiation of the rpt
name and OwnerCode) but that meams that you will accumulate files even if
you did not print them. Altenatively prompt you, with the report name before
you save the file.

Which is more suitable?

Regards/Jacob
 
B

Bob

OwnerPaymentMethos1, OwnerPaymentMethos2 etc. Would be Fine thanx
The Snap shot opens 100% but the box is only 1/4 the size of the screen so
have to maximize it
can I get a error message about the folder because if there is no Statement
folder Access freezes up
Thanks Jacob for your help
 
J

JK

No worries, back in about an hour

Bob said:
OwnerPaymentMethos1, OwnerPaymentMethos2 etc. Would be Fine thanx
The Snap shot opens 100% but the box is only 1/4 the size of the screen so
have to maximize it
can I get a error message about the folder because if there is no
Statement folder Access freezes up
Thanks Jacob for your help
 
J

JK

Bob,
Sorry I was held up

Following a function which will do both, it will create C:\statements if it
does not exist and number the file names
xxxx.snp, xxxx1.snp, xxxx2.snp etc -it will use the *first available* number
eg if xxxx2.snp is missing but you have xxxx1.snp and xxxx3.snp it will
write into xxxx2.snp

Copy this function next to your cmdStatemet_Click()

Below the finction is an example how to use it.

I tested it best I could, hopefully it will not give you grief.

Here we go:


Private Function bAutoRenameFile( _
strTestName As String)

'For Bob:
'output: returns unique Snapshot file in C:\Staements
'by adding a number at end of the file name
'eg "Test1.snp", "test2.snp" etc
'where (strTestName="Test"or "test.snp"
'Return the original string on unresoved errors
'if C:\Statements does not exist it will create it
'after prompting

On Error GoTo ErrorHandler

Dim fs As Object, _
strFile As String, _
strDir As String, _
strSfx As String, _
numSfx As Long, _
nPos As Long, _
tmpStr As String

'fs: FilseSearch object
'strFile: File name withot extension (if any)
'strDir: path to file
'strSfx: File extenstion
'numSfx: suffix number to add/replace to file name
'nPos: position in string
'tmpStr: temporary stroarge

'Msg\InputBox parameters:
Dim msgPmt As String, _
msgBtns As Integer, _
msgTitle As String, _
msgResp As Integer, _
inpPmt As String

'initialising
'strDefDir = Application.CurrentProject.Path
bAutoRenameFile = ""
tmpStr = Trim(strTestName)
msgTitle = "bAutoRenameFile Function"

'---- test for empty file name
msgBtns = vbExclamation
inpPmt = "Empty file name is not allowd!" & Chr(13) _
& "Please enter a valid file name: "

If Len(tmpStr) = 0 Then
GoTo GetFileName
Else
GoTo TestFileName
End If

GetFileName:
tmpStr = Trim(InputBox(inpPmt, msgTitle, tmpStr))

If Len(tmpStr) = 0 Then
msgBtns = vbYesNo + vbExclamation
msgPmt = "No file Name Entered " & Chr(13) _
& "Re-enter file name? "
msgResp = MsgBox(msgPmt, msgBtns, msgTitle)
If msgResp = vbYes Then
GoTo GetFileName
Else
bAutoRenameFile = strTestName
Exit Function
End If
End If


TestFileName:
nPos = InStrRev(tmpStr, ".")
If nPos = 0 Then 'no extension entered
strFile = tmpStr
strSfx = ".snp"
Else
strFile = Left(tmpStr, nPos - 1)
strSfx = Right(tmpStr, Len(tmpStr) - nPos + 1)
End If
strDir = "C:\Statements"


'---- Test directory exists and make it if not
If Len(Dir(strDir, vbDirectory)) = 0 Then
msgBtns = vbOKCancel + vbQuestion
msgPmt = "Directory '" & strDir & "' dose bot exist! " _
& Chr(13) & "Create Direcory?"
msgResp = MsgBox(msgPmt, msgBtns, Left(msgTitle, 23))
If msgResp = vbCancel Then
bAutoRenameFile = strTestName
Exit Function
End If
MkDir strDir
GoTo EndExit
End If

'-----Look For exiting files
numSfx = 0
Set fs = Application.FileSearch

LookForDup:
'strFile = strFile & IIf(numSfx = 0, "", numSfx)
tmpStr = strFile & IIf(numSfx = 0, "", numSfx)

With fs
.lookin = strDir
.FileName = tmpStr & strSfx
If .Execute > 0 Then 'File found
numSfx = numSfx + 1
GoTo LookForDup
End If


End With

EndExit:
bAutoRenameFile = strDir & "\" & tmpStr & strSfx
Exit Function

ErrorHandler:
msgBtns = vbExclamation
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Descrtpion: " & Err.Description

bAutoRenameFile = strTestName
Exit Function


End Function

+++++++++++++++++

Here is the beginibg of your sub using the function

Private Sub cmdStatement_Click()
'bob's Statements

Dim saveReport As interder, savFileName As String

Select Case Me.OpenArgs

Case "OwnerStatement"

If IsNull(cbOwnerName.Value) = True Or _
cbOwnerName.Value = vbNullString Then
MsgBox "Please Select the Owner.", _
vbApplicationModal + vbInformation _
+ vbOKOnly 'added + ( to vbokonlt)
Exit Sub
End If
'**************************************
savFileName = bAutoRenameFile("rptOwnerPaymentMethos.snp") '
**** added
'will return "rptOwnerPaymentMethos1.snp",
'"rptOwnerPaymentMethos2.snp"
' etc
savFileName = "C:\Statements\" & savFileName '**** add
' savFileName = "C:\Statements\" & "rptOwnerPaymentMethos" _
'removed
' & ".SNP"
' ***********************************************
DoCmd.OutputTo acOutputReport, "rptOwnerPaymentMethos", _
"Snapshot Format", savFileName, True
' ......... etc


Regard/Jacob
 
J

JK

Thanks David

In the control bar, do you see a blue W? The W stands
for Word, and the control tip is OfficeLinks? That exports
to RTF.
Or, from the file menu, select SaveAs, and save as RTF or
snapshot.

(david)
 
B

Bob

Jk , Error : The report snapshot created because not enough free
disk................
I am getting a yellowed out on,
DoCmd.OutputTo acOutputReport, "rptOwnerPaymentMethod", _
"Snapshot Format", savFileName, True
Thanks Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top