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.