Reports by Name

N

Nikki

Hi,

Its been a while since I have created any reports in a database and need a
little reminder.

I have a basic database for tracking employee training with information
about the employee and then what courses they have done. I have created a
report that lists all the employees and their courses but I would like to be
able to create one that is just for the individual. I would like a box to
pop up when the report is open that prompts the user to enter the name of the
employee. Then I would like the report to show that persons name and any
courses they have done. I am unsure about how to get this box to pop up?

Any help....
 
A

Allen Browne

A nice interface for this would be to create a form with a combo box (for
selecting the employee) and a command button (for opening the report.)

In the Click event procedure of the button, yuo then build the
WhereCondition for OpenReport like this:

Dim strWhere As String
If Not IsNull(Me.Combo1) Then
strWhere = "[EmployeeID] = " & Me.Combo1
End If
DoCmd.OpenReport "Report1", acViewPreview, , strWhere

Notes
====
1. If your primary key is a Text type field (not a Number type field), you
need extra quotes:
strWhere = "[ID] = """ & Me.[ID] & """"
For an explanation, see:
http://allenbrowne.com/casu-17.html

2. The report will not filter correctly if it is already open.

3. If you want the report to print without preview, replace acViewPreview
with acViewNormal.

4. For a more comprehensive example that handles many optional criteria,
see:
http://allenbrowne.com/ser-62.html
 

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