Help: Input Prompt to Print a Form by Category?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm developing a small database for a user at my workplace and I need a prompt that will ask what district to print, then print just the corresponding records for the specified district. I've experimented with a few macros and had poor results. Although I'm sure there's a way to do this in VBA, I only have a novice understanding of it. Any help or suggestions would be greatly appreciated. Thanks in advance.
-Paul
 
I am guessing you have a button to print the report.

Add a combo box to the same form as where you run the report.
This combo box will list all of your districts and allow the user to select
one.
You could call the combo [DistrictSelect].
The combo Control Source could be something like:
SELECT DISTINCT tblYourTable.District FROM tblYourTable;


Then for the Control Source of your report use something like this:

SELECT tblYourTable.* FROM tblYourTable WHERE
tblYourTable.District=[screen].[activeform]![DistrictSelect];
or
SELECT tblYourTable.* FROM tblYourTable WHERE
tblYourTable.District=[forms]![frmYourForm]![DistrictSelect];

HTH
Mich


Paul said:
I'm developing a small database for a user at my workplace and I need a
prompt that will ask what district to print, then print just the
corresponding records for the specified district. I've experimented with a
few macros and had poor results. Although I'm sure there's a way to do this
in VBA, I only have a novice understanding of it. Any help or suggestions
would be greatly appreciated. Thanks in advance.
 
I would create a query and base a report on this query. In the query you
will type:
Like [Enter district] & "*" in the criteria section of 'district field'.
Then create a button on your form that points to this report. When the user
clicks the button they will be prompted for a District value.

They can type the District name or number in full or partial. Thus if your
districts are numbers and they want all districts that start with 1 they can
type the value '1' and will get data for 1, 10,11, 12, 100 etc. If they want
a specific district they can type '12' and get only twelve (unless you have
a district 120 or higher).

If they press enter without typing a value, they will get everything. If
you want them to type the district value exact each time, remove the word
Like and "*" from the statement.

Paul said:
I'm developing a small database for a user at my workplace and I need a
prompt that will ask what district to print, then print just the
corresponding records for the specified district. I've experimented with a
few macros and had poor results. Although I'm sure there's a way to do this
in VBA, I only have a novice understanding of it. Any help or suggestions
would be greatly appreciated. Thanks in advance.
 
Is it safe to assume you are basing your report on a table?

If so instead of the table name in the record source put

Select * from table where table.district = [Please enter the District]

Any time the report is opened in report view or to be printed the user will be prompted for the district.
 
Back
Top