M
Melissa
I put a command button on my form. I then placed the code you provided in the
code builder window using the on click event, only entering the name of the
report. Code as follow.
DoCmd.OpenReport "Agent Production Report", , , _
"[EmpID] = " & Me.EmpID.Value & _
" And [DateCompleted] = #" & _
Format(Date, "mm\/dd\/yyyy") & "#"
The error I am getting is "The specified field '[EmpID]' could refer to more
than one table listed in the FROM clause of your SQL Statement.
Now I do understand this because there is a main form with a subform within
this form and both tables have EmpID.
I have made a work around and put a command button on the form to preview
the report. But the query will prompt them to enter their name. On the date
completed I put =Date() so that part worked. I just need to eliminate the
need for them to enter thieir name.
Any suggestions.
thanks again..
code builder window using the on click event, only entering the name of the
report. Code as follow.
DoCmd.OpenReport "Agent Production Report", , , _
"[EmpID] = " & Me.EmpID.Value & _
" And [DateCompleted] = #" & _
Format(Date, "mm\/dd\/yyyy") & "#"
The error I am getting is "The specified field '[EmpID]' could refer to more
than one table listed in the FROM clause of your SQL Statement.
Now I do understand this because there is a main form with a subform within
this form and both tables have EmpID.
I have made a work around and put a command button on the form to preview
the report. But the query will prompt them to enter their name. On the date
completed I put =Date() so that part worked. I just need to eliminate the
need for them to enter thieir name.
Any suggestions.
thanks again..
Ken Snell said:Yes, you have properly related the Employeetbl to EmployeeHrs, and
Employeetbl linked to Corresp Reced Completed through the EmpID fields.
Yes, the code I posted would be used "as is" except change ReportName to the
actual name of the report.
--
Ken Snell
<MS ACCESS MVP>
Melissa said:Ok, I understand your answer on both but, I have follow ups.
On how I have my relationships set up currently,
Employeetbl linked to EmployeeHrs (one to many)
and also the Employeetbl linked to Corresp Reced Completed (one to many).
Both by EmpID fields. Is this good? I just don't want to run into any
problems in the future.
Also, the button I could put on the form to run the report. Will the only
area I need to for the line of code is the Report Name?
Thanks again .
Ken Snell said:Comments inline...
--
Ken Snell
<MS ACCESS MVP>
Hi Ken,
I think I have everything in place. I have three tbls. I am only giving
the
primary keys in the examples below.
EmployeeHrs
EmpID
DateCompleted (are composite keys)
etc.
Employee tbl
EmpID (primary key)
Correpondence Received Completed tbl
DateCompleted
AuditType
EmpID (these three fields are composite keys) Great advice on the
composite
keys by the way.
I would think that you also would want a tblAuditTypes table to hold the
AuditType values, and its primary key would be the foreign key
"AuditType"
in the Correpondence Received Completed tbl.
My question is, I have my Employeetbl linked to EmployeeHrs (one to
many)
and also the Employeetbl linked to Corresp Reced Completed (one to
many).
Should I link the EmployeeHrs to the Corresp Reced Completed tbl (one
to
many)? When I try to do this I get a relationship type of
"Indeterminate",
what is that? I will begin to work on my reports next week and I do not
want
to run into trouble.
No, there is no need to have any type of link between EmployeeHrs and
Correpondence Received Completed tbl. The EmployeeHrs contains no field
that
would connect to the purpose of the Correpondence Received Completed tbl.
The reason for the "Indeterminate" error (when, I assume, you try to
create
a relationship between EmpID field in both tables) is because neither
table
uses EmpID as a primary key (by itself), so ACCESS would see this join as
a
"many-to-many", which it does not support directly for a relationship
setting.
Second Question:
I have my Data Entry form set up and is running great. If you recall,
My
main form is Employee Hrs (which can only have one record per day per
agent)
and the Subform is Correp Recd Completed (which can have multi entries
per
day by the same agent but, not the same Audit type).
Based on that, if an employee wants to print their production that they
entered that day, how can I set this up with a button? If they print
record
it comes up blank because of the form being set to data entry only.
Also,
if
that is change only the main form can be printed?
You'd want a report that is based on a query that uses the Employee tbl
and
the Correpondence Received Completed tbl, joined by the EmpID fields.
Then
you could code a button on the form that would open the report, which you
would filter based on the current date and the EmpID:
DoCmd.OpenReport "ReportName", , , _
"[EmpID] = " & Me.EmpID.Value & _
" And [DateCompleted] = #" & _
Format(Date(), "mm\/dd\/yyyy") & "#"
Thank you so much for all your guidance. You have been a great help to
me.
You're welcome.
< snipped >