How can I make the new form, EmpCalc show the records that the main form
TimeCards via the sub-form shows, i.e. Time and Hours?
I tried but it didnt work!
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.OpenForm "EmpCalc", "", "[HoursID]=[Forms]![Time_Hours]![HoursID]"
'stDocName = "EmpCalc"
DoCmd.OpenForm stDocName, , , stLinkCriteria
There are syntax errors in both your examples. Try it like this...
DoCmd.OpenForm "EmpCalc", , , "[HoursID]=" &
[Forms]![TimeCards]![Time_Hours].Form![HoursID]
Or, if the EmpCalc from is being opened, as I imagine may be the case,
via an event on the Time_Hours subform, it would be more like this...
DoCmd.OpenForm "EmpCalc", , , "[HoursID]=" & Me.HoursID
By the way, is it supposed to be [Time_Hours] or [Time and Hours]?
--
Steve Schapel, Microsoft Access MVP
'Set Me.Form.Recordset = Forms("Time and Hours").Form.Recordset
DoCmd.OpenForm "EmpCalc", , , "[Employee ID]=" &
[Forms]![TimeCards]![Time_Hours].Form![Employee ID]
"Steve Schapel" <sch...@mvps.org.ns> wrote in message
news:e0XUlX8Y...@TK2MSFTNGP14.phx.gbl...
In that case, if I understand your earlier psot correctly, you should be
using the TimeID in the Where Condition, not the Employee ID. Maybe
like this?...
DoCmd.OpenForm "EmpCalc", , , "[TimeID]=" &
[Forms]![TimeCards]![Time_Hours].Form!TimeID
Just try and work out what criteria will determine the records you want.
Obviously if you use the Employee ID as the criteria, you will get all
the records for that Employee.
"Dave Elliott" <mynot...@sbcglobal.net> wrote in message
news:KC7me.3802$3D6...@newssvr12.news.prodigy.com...
I am not really able to answer that question, on the basis of the
information I have at present. But here's the concept... Think about
the table or query that is the Record Source of the EmpCalc form. Ok,
which field(s) need to have a criteria applied in order for you to
obtain the records you require? Ok, which form(s) have data in the
current record which will determine these criteria? Ok, so that's what
you have to use. As I mentioned before, the syntax of your code will
also depend on the where the code is being called from, which only you know.
Set Me.Form.Recordset = Forms("Time and Hours").Form.Recordset
"Dave Elliott" <mynot...@sbcglobal.net> wrote in message
news:bd8me.3807$3D6....@newssvr12.news.prodigy.com...
I imagine the records shown in the Time and Hours subform are
restricted, not via the query that is the record source of the form, but
via the link to the TimeCards form. If you have a look at the Link
Master Fields and Link Child Fields properties of the subform, you will
see what field(s) are involved.
As regards controlling the records included in the EmpCalc form, you can
do this via a criteria in the query that it is based on. This is
probably the way I would do it. Or you can do it, as discussed
previously, via the Where Condition argument of the OpenForm method when
opening the EmpCalc form. If you need more specific help with these,
you will need to supply more detailed information, as I indicated
previously.
Then, you should use:
DoCmd.OpenForm "EmpCalc", , , "[Employee ID] = " & me![Employee ID]
Remember, the 'where' clause is simply standard sql. The above says:
for all records in form EmpCalc, restrict the data to a field called
[Employee ID] to the current employee id in our main form (me!Employee ID]
By the way, in the future...stay away from putting spaces in field
names..they are VERY nasty, and can cause all kinds of problems. (and, sql
server, oracle, and most database systems do not support spaces anyway).
Further:
"[Employee ID] = " & me![Employee ID]
^^^^ above is name of field in the table EmpCalc is attached to
So, if the name of the field in the EmpCalc is NOT [Employee ID], then
change the above to whatever it is supposed to be
"[Employee ID] = " & me![Employee ID]
^^^^ above is name of field in
our main form here. Again, if the name of the employeeID field in our main
form is not as above, then change it.
it is not clear if the button you are talking about is on the main form, or
the sub-form. The above assumes your button is on the main form.
There is NO need to reference, or look at the values in the sub-form here,
since all you are doing is restricting the new form to all records that
belong
to our "parent" record.
One more thing, if you allow editing in your sub-form, and then open another
form with all those sub-form records, you can get a conflict. This means
BEFORE you open that new form, you need to FORCE a disk write of the
sub-form records. Hence, you need:
me.MySubFormContorlName.Form.Refresh
DoCmd.OpenForm "EmpCalc", , , "[Employee ID] = " & me![Employee ID]
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOO...@msn.com
http://www.members.shaw.ca/AlbertKallal
--
Steve Schapel, Microsoft Access MVP
"Steve Schapel" <sch...@mvps.org.ns> wrote in message
news:uVRGhfIZ...@TK2MSFTNGP09.phx.gbl...
The idea is too count how many days where there are more than 2 employees
who worked on the same job,i.e. TimeCounter (Invoice Number) of course the
regular rate for 2 or less
employees still counts as well and has to be figured in.
this is necessary because the rate changes at which the customer is billed
when the count of employees
is more than 2 on any given day. For one or two employees the rate 65.00 a
hour, for each employee after
that the rate becomes 1/2 the rate added to the original rate (32.50). Now
the rate becomes 97.50 for each hour
that 3 employees worked on for the same day.so the calculation gets
complicated for me as you can see.
Example: Forest Gump works on Monday 05/30/05 as well as Bubba Gump and
Billy Bob and the total hours worked
is 24. Then the customer will be billed for 24 hours @ 97.50 AN HOUR.
If on Tuseday for the same Invoice Number, i.e. TimeCounter only 2 employees
worked 8 hours each, then the rate of 65.00 a
hour will be used to calculate at 16 hours * 65.00. this will be added to
the existing time for Monday and the
final total will be billed to the customer.
So the calculation must be performed for each day;
Lost as to how to proceed!
I have the data on the form, just need to sort it out so it can be
calculated.
Thanks,
Dave
I definitely would not be trying to perform this type of calculation on
a form. I would be doing this in a query, or else writing a
user-defined function specific to the purpose. Do you have a table with
the same fields as you described, i.e. EmployeeID, WorkDate, Hours,
Overtime?
--
Steve Schapel, Microsoft Access MVP
SQL is below:
SELECT Hours.SinMar, Hours.NoAllow, Hours.PayRate, Hours.Hours,
IIf([TEmpOrCon].[EmpOrCon]=0.2,1*[PayRate],[Hours]*[PayRate]) AS RegPay,
Hours.OTRate, Hours.Overtime, [Hours].[OTRate]*[Overtime]*[PayRate] AS
OTPay, [RegPay]+[OTPay] AS ExpPayPerDay, Hours.TimeID, Hours.HoursID,
Hours.EmployeeID, Employees.[First Name], Hours.[Work Date], Employees.[Last
Name], Hours.ChkNoID, IIf(IsNull([ChkNoID]),0,-1) AS Paid
FROM (Hours LEFT JOIN Employees ON Hours.EmployeeID = Employees.[Employee
ID]) LEFT JOIN TEmpOrCon ON Employees.EmpOrCon = TEmpOrCon.EmpOrConID
ORDER BY Hours.[Work Date] DESC;
"Steve Schapel" <sch...@mvps.org.ns> wrote in message
news:O0fqxYUZ...@TK2MSFTNGP15.phx.gbl...
THANKS,
DAVE
"Dave Elliott" <mynot...@sbcglobal.net> wrote in message
news:NiKme.243$JQ6...@newssvr11.news.prodigy.com...