I am attempting to use the following code to print a report based on
the current record in the form. Users bring up the record with a
parameter box and then can make changes to the sub-form on the main
form (main form is locked). I use this same code for another
form/report and it works. The only difference is the parameter. The
one that works opens to all records and then the user uses the filter
by form. I don't want them to do that on this form. Can anyone help?
Thanks - Karen
Private Sub Command91_Click ()
On Error GoTo Err_Command91_C lick
Dim strWhere As String
If Me.FilterOn Then
strWhere = Me.Filter
End If
DoCmd.OpenRepor t "rptJobReco rd-Auto", acViewPreview, , strWhere
Dim stDocName As String
stDocName = "rptJobReco rd-Auto"
DoCmd.OpenRepor t stDocName, acPreview
Exit_Command91_ Click:
Exit Sub
Err_Command91_C lick:
MsgBox Err.DESCRIPTION
Resume Exit_Command91_ Click
End Sub 2 7249
Dim strWhere As String
If Me.FilterOn Then
strWhere = Me.Filter
End If
DoCmd.OpenRepor t "rptJobReco rd-Auto", acViewPreview, , strWhere
Your strWhere should be something like....
[PrimaryKeyOfTab le] = Me.PrimaryKeyFi eldControlOnFor m
Oh, and it should be delimited properly
Text - use single quotes.
Dates - use # signs
numbers - use nothing.
Something like
Const cQUOTE = "'"
strWhere = "[IDNo]=" & cQuote & Me.TextIDField & cQUOTE
DoCmd.OpenRepor t "rptJobReco rd-Auto", acPreview, strWhere
HTH
Access 97 HELP - Create a report displaying only the current record
selected.
Hello guys, This is how I did it.
1. Create your report. The report does not need to be based on a
query or have a datasource.
2. Drop unbound text boxes into the reports to hold your fields. Type
the names of the fields in your form into the report text boxes in the
following format:
=[Forms]![nameOfYourFormG oes Here]!nameOfFieldGoe s Here
This is telling the report to use the currently selected record of the
specified form as the source for the specified field. Obviously for
the report to work the form must be open and a record selected.
3. Save your report. Go into Macros section, and create a new macro.
Set the first action for your Macro to 'OutputTo'. Set object type to
'Report', set object name to the name of your report, set output
format to Rich Text Format, and set the other fields here according to
your preference. Save the macro.
4. Open your form in design view and drop a command button into an
appropriate place. In the properties for your button, under 'on click'
select your newly create macro.
5. Then, go into the form properties and make sure the Source is blank
instead of referring to the table.
Thank you Boiled Egg and Larry Daugherty! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Aftershock |
last post by:
I have looked on the groups but can't seem to find an answer. I have a
parameter query that uses a form for its input. This form then opens
up a search result form based on the query. It is from this form that
I want to print via a report all of the returned records shown on the
form.
I can print off a single current record shown in the form (say record
3 of 5) using this code:
Private Sub cmdPrintCurrent_Click()
|
by: Andrew |
last post by:
What I'm trying to have done is the following:
After data is entered into a form, I want the user to click the
"Submit and print" button, which solidifies the data in the tables,
then prints a report based on the most recent data.
Do I need an autonumber column and have the report be based off the
largest record number or is there an easier way to do it? Also, I'm
not at all familiar with VBA (my small DB experience is in Perl and...
|
by: Paul Mendez |
last post by:
I have a form that consists of 150 records and is still growing.
there are times when I want to print a certain record of the form, say
record 12. I go to file --> print and choose the page number of the
record. But what I would like to do, to decrease the amount of
mistakes of print all 150+ records, I would like a button to only
print the record that is currently displayed on screen. I know it can
be done, I just don't know how. Any...
|
by: sea |
last post by:
I need to be able to print the current form because the form has an
embedded object of a .gif file, so report will not work -- does anyone
know the way to do this? I tried some code, not sure what it was now,
guess docmd.printout or something but that prints ALL the forms --
also the each page of the form does not always start at the next page
even if allowcontinuousforms is set to no. The preview button previews
all the forms as well,...
|
by: Glenn Zamora |
last post by:
I am new to MS Access. I have created a simple entry form to track
patient information. I have also created a Patient Report that prints
Patient Information with a standard disclaimer statement. I added a
print button to my entry form hoping that the patient information that I
enter will merge with the Patient Report however I must be missing a
step because when I click on the print button it prints all patients in
the database. Is there...
| |
by: hosi |
last post by:
Hi, suppose I want to print third record from a subform.
The problem is, that when I want to print what I see on my monitor
(third record), the print preview resets
the form to the first record (wants to print the whole form beginning).
Is the any possibility to print a particular record, without making
screenshots?
Please, help me!!!
|
by: thh108688 |
last post by:
Hi All,
Is anyone know how to do a print report based on my current record. What i would like to get is once i have entered all the value in the form, when i hit the print button, all the value will be printed in a nice word document.
It is good if someone can give me an example when explaining as i am quite new with Access. Sick of coding!
Appreciate for that!
Cheers
Ray
|
by: Studiotyphoon |
last post by:
Hi,
I have report which I need to print 3 times, but would like to have
the following headings
Customer Copy - Print 1
Accounts Copy - Print 2
File Copy -Print 3
I created a macro to print the report three times, but do not know how
|
by: Gord |
last post by:
When I open a certain report, it runs some code that generates the records
that will be displayed in that report. This works fine. When I go to print
preview the report it appears that the code is run again? This is causing
certain error problems.
1 Why does the code run for a print preview when the report already
exists?
2 What command do I use in code to find out if a report (or any other
object for that matter) is already...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |