A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Print and Close Command



 
 
Thread Tools Display Modes
  #1  
Old May 2nd, 2005, 10:54 PM
jeannette_rivera
external usenet poster
 
Posts: n/a
Default Print and Close Command

Need a Print and Close Command to be use in some Access Unbound Forms.
  #2  
Old May 2nd, 2005, 11:00 PM
Rick B
external usenet poster
 
Posts: n/a
Default

The wizard will walk you through building a print button and also a close
button. Just copy and paste the code to combine it into one button.



--
Rick B



"jeannette_rivera" wrote in
message news
Need a Print and Close Command to be use in some Access Unbound Forms.



  #3  
Old May 2nd, 2005, 11:23 PM
jeannette_rivera
external usenet poster
 
Posts: n/a
Default

I had those two command in different buttons, how can I mix both to get the
print and close.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.PrintOut
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
DoCmd.Close
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub

"Rick B" wrote:

The wizard will walk you through building a print button and also a close
button. Just copy and paste the code to combine it into one button.



--
Rick B



"jeannette_rivera" wrote in
message news
Need a Print and Close Command to be use in some Access Unbound Forms.




  #4  
Old May 3rd, 2005, 04:07 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.PrintOut
DoEvents
DoCmd.Close

Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

HTH
Van T. Dinh
MVP (Access)



"jeannette_rivera" wrote in
message ...
I had those two command in different buttons, how can I mix both to get

the
print and close.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.PrintOut
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
DoCmd.Close
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub



  #5  
Old August 10th, 2006, 02:57 AM posted to microsoft.public.access.forms
Doug
external usenet poster
 
Posts: 616
Default Print and Close Command

Rick - Can't seem to get to post here any other way - hope you see this. Am
trying to create a command button on a data entry form that once I have
filled in the data, I can click on and it will print JUST that record on
another form in the DB. HELP!

"Rick B" wrote:

The wizard will walk you through building a print button and also a close
button. Just copy and paste the code to combine it into one button.



--
Rick B



"jeannette_rivera" wrote in
message news
Need a Print and Close Command to be use in some Access Unbound Forms.




  #6  
Old August 10th, 2006, 03:02 AM posted to microsoft.public.access.forms
Doug
external usenet poster
 
Posts: 616
Default Print and Close Command

Van - Sorry - could not get the system to let me post any other way - hope
you see this. Am trying to create a command button on a data entry form that
once I have filled in, I can click on, and it will print out another form for
only the data in the current record. Can't seem to figure it out/ HELP!

"Van T. Dinh" wrote:

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.PrintOut
DoEvents
DoCmd.Close

Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

HTH
Van T. Dinh
MVP (Access)



"jeannette_rivera" wrote in
message ...
I had those two command in different buttons, how can I mix both to get

the
print and close.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.PrintOut
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
DoCmd.Close
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub




  #7  
Old August 10th, 2006, 05:36 AM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default Print and Close Command

On Wed, 9 Aug 2006 18:57:01 -0700, Doug
wrote:

Rick - Can't seem to get to post here any other way - hope you see this. Am
trying to create a command button on a data entry form that once I have
filled in the data, I can click on and it will print JUST that record on
another form in the DB. HELP!


Don't print Forms - print REPORTS.

Are you storing the data in a Table (I hope)? or are you just trying
to print the volatile, unstored data on the form?

John W. Vinson[MVP]
  #8  
Old August 10th, 2006, 06:30 AM posted to microsoft.public.access.forms
Doug
external usenet poster
 
Posts: 616
Default Print and Close Command

John - yes - absolutely all is stored in tables, no transient data. I can
get it to print a report, but it tries to print all 806 records, not just the
currently selected record

"John Vinson" wrote:

On Wed, 9 Aug 2006 18:57:01 -0700, Doug
wrote:

Rick - Can't seem to get to post here any other way - hope you see this. Am
trying to create a command button on a data entry form that once I have
filled in the data, I can click on and it will print JUST that record on
another form in the DB. HELP!


Don't print Forms - print REPORTS.

Are you storing the data in a Table (I hope)? or are you just trying
to print the volatile, unstored data on the form?

John W. Vinson[MVP]

  #9  
Old August 10th, 2006, 05:42 PM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default Print and Close Command

On Wed, 9 Aug 2006 22:30:01 -0700, Doug
wrote:

John - yes - absolutely all is stored in tables, no transient data. I can
get it to print a report, but it tries to print all 806 records, not just the
currently selected record


Two options:

1. Base the Report on a Query which references a control on the form
as a criterion, using the syntax

=[Forms]![YourFormName]![YourControlName]

2. Edit the wizard-generated OpenReport code in the click event to
include a WhereCondition. It should have a line like

stCriteria = ""

Edit this to something like

stCriteria = "[ID] = " & Me.txtID

using your own field and control names.

John W. Vinson[MVP]
  #10  
Old August 19th, 2006, 08:48 AM posted to microsoft.public.access.forms
Doug
external usenet poster
 
Posts: 616
Default Print and Close Command

John -

I don't know if you remember or not, but I corresponded with you on a
problem I was having getting a command button on a Form to display a report
based ONLY on the current record. I have gotten OH SO CLOSE, but am still
apparently oh so far away, and am once again stymied. I am hoping you will
be able to help me find "the error of my ways"...

I own and run a small business that does covenant enforcement for Home
Owners Associations here in Colorado. I built this Access database a long
time ago to help me manage the many violations I have to write, and decided
recently, "Why am I writing these? I could just enter the data on the
computer in my vehicle and have it print each citation on the fly for me!?"
It has turned out for my feeble coding skills to be much easier said then
done, but I am determined to somehow lick it.

If you remember, I had a data entry form up, that I wanted to place a
command button on to print a report (a parking violation citation to be
precise) that when I clicked it, it sent the citation for that record to the
printer.

I entered the following code for the command button:

Private Sub CitationPrintPreview_Click()

Dim strReportName As String
Dim strCriterea As String

If NewRecord Then
MsgBox "This record contains no data. Please select a record to
print or Save this record.", vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "Citation"
strCriterea = "[Cite_#]= " & Me![Cite_#]
'strCriterea = "[Cite_#]='" & Me![Cite_#] & "'"

DoCmd.OpenReport strReportName, acViewPreview, , strCriterea

End If
End Sub

It's the closest I have gotten to success so far, however, when I execute
it, I am presented with the error message that says:

Run Time Error '3075';

Syntax Error (missing operator) in query
expression'([Cite_#]=20010317DD090032)'

The number displayed (20010317DD090032) is the correct citation number for
the record that is currently being displayed on the form that I want to print
a citation for, but I can't for the LIFE of me figure out what I'm missing or
what I have screwed up. Can you help me sir, please? Thank you SO much in
advance for your time and help with this - I really do appreciate it.

- Doug Brown


"John Vinson" wrote:

On Wed, 9 Aug 2006 22:30:01 -0700, Doug
wrote:

John - yes - absolutely all is stored in tables, no transient data. I can
get it to print a report, but it tries to print all 806 records, not just the
currently selected record


Two options:

1. Base the Report on a Query which references a control on the form
as a criterion, using the syntax

=[Forms]![YourFormName]![YourControlName]

2. Edit the wizard-generated OpenReport code in the click event to
include a WhereCondition. It should have a line like

stCriteria = ""

Edit this to something like

stCriteria = "[ID] = " & Me.txtID

using your own field and control names.

John W. Vinson[MVP]

 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically Close report in print preview Pierre Setting Up & Running Reports 2 April 24th, 2005 08:19 PM
If Statement for Close of Form Dave Elliott Using Forms 7 September 11th, 2004 02:45 AM
How do I print the details view David Running & Setting Up Queries 5 August 28th, 2004 12:17 AM
Load form, print it, close it. Ynot New Users 7 June 28th, 2004 08:22 PM
Missing close button on print preview Hana Setting Up & Running Reports 5 May 25th, 2004 07:16 PM


All times are GMT +1. The time now is 12:48 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.