Names for a Report

G

Guest

I have a report that I’ve created that is used to give info about and
individual employee. When I click on the report, I have to type in the
employee’s name to generate the report. What I would like to do is get the
name of the employee from my dropdown box on my reports form. Currently I
pull the date for query off of my reports form. Any suggestion on just how
to do this.

Thanks
 
G

Guest

You can reference your employee from the field on your form by pointing to
the field in your criteria. If you are doing it for the date field, it
should be similar to that. The criteria on your employee field in the query
would be something like:
Forms!frmReportMenu!EmployeeField

Hope this helps.
 
G

Guest

Hi, Todd.
What I would like to do is get the
name of the employee from my dropdown box on my reports form. Currently I
pull the date for query off of my reports form. Any suggestion on just how
to do this.

Since your reports form must be open when the report opens, why not use a
button to open the report after the date and employee have been selected on
the form? Use the WhereCondition argument of the OpenReport method to
indicate the date and the primary key for the employee's record, and remove
the date criteria from the query's WHERE clause. For example:

Private Sub RunRptBtn_Click()

On Error GoTo ErrHandler

DoCmd.OpenReport "rptEmployee", acViewPreview, , _
"SomeDate = #" & Me!txtSomeDate.Value & _
"# AND EmpID = " & Me!cboEmployee.Column(0)

Exit Sub

ErrHandler:

MsgBox "Error in RunRptBtn_Click( ) in" & _
vbCrLf & Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

.. . . where RunRptBtn is the name of the button, rptEmployee is the name of
the report, SomeDate is the name of the field with the date you're intested
in, txtSomeDate is the name of the text box on the form displaying this date,
EmpID is the name of the primary key field, cboEmployee is the name of the
combo box displaying the employee information, and Column(0) is the first
column, which contains the primary key, EmpID, an AutoNumber.

The cboEmployee combo box could use the following query for the Row Source
Property for the two columns needed:

SELECT EmpID, (FirstName & " " & IIF(ISNULL(MI), NULL, MI & ". ") &
LastName) AS FullName
FROM tblEmployees
ORDER BY LastName, FirstName, MI;

.. . . where tblEmployees is the name of the table with the employee's
records, and EmpID is the primary key.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
G

Guest

This is what I have in my SQL Statement.

[Employees].[FirstName] & " " & [Employees].[LastName]

Group By

[Enter Name]

I have used Form!View Reports!Name But nothing happens. I maybe
putting it in the wrong place. I was replacing the [enter name]

[Employees].[FirstName] & " " & [Employees].[LastName]

Group By

Form!View Reports!Name
Name is the name of my unbound field. I still can not get it to work.
 
G

Guest

I have one button that opens up my reports. I just select what report I want
then click on the open button. The date part works fine I just can not get
the names to pass along.
 
G

Guest

Hi, Todd.
I have used Form!View Reports!Name But nothing happens.

You have a typo, illegal characters in an identifier, and an illegal
identifier. "Form" should be Forms. "View Reports" has a space within it.
"Name" is a Reserved word. Only use alphanumeric characters and the
underscore when naming an identifier, and avoid Reserved words, and you won't
waste much time chasing bugs. For a list of Reserved words to avoid, please
see the following Web pages:

http://support.microsoft.com/default.aspx?id=321266

http://support.microsoft.com/default.aspx?scid=286335

Change the name of your View Reports form so that it's all one word, such as
either ViewReports or View_Reports. Change the unbound Name text box to
something like txtName or txtFullName.
I maybe
putting it in the wrong place.

Fix the naming errors and the typo, and you may find that you've put it in
the correct place after all. However, there are several places where this
expression could be placed correctly, so if it doesn't work after you've
fixed it, post again with the new expression and explain where you've placed
this expression.

The problem with using [Employees].[FirstName] & " " &
[Employees].[LastName] as filter criteria is that it needs to match a column
in the record source of the report precisely. It's easier to just filter the
records on the primary key when it's a surrogate key like an AutoNumber field.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


Todd said:
This is what I have in my SQL Statement.

[Employees].[FirstName] & " " & [Employees].[LastName]

Group By

[Enter Name]

I have used Form!View Reports!Name But nothing happens. I maybe
putting it in the wrong place. I was replacing the [enter name]

[Employees].[FirstName] & " " & [Employees].[LastName]

Group By

Form!View Reports!Name
Name is the name of my unbound field. I still can not get it to work.
 

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

Top