M
Marshall Barton
Ok, I think I understand it better now.
Assumong that employeename is a Text field, the Dcount
should then look more like:
=DCount("*","sicknessabsences","employeename='" & [sickname]
& "' And paid=Forms]![frm x main]![month name] And
absencetype='s' ")
Note that if [month name] is changed while
frmSicknessAbsence is open, you will need to at least
Requery the DCount text box and ony other item that uses
[month name] as a criteria. Actually, looking back at the
form's record source, is see that frmSicknessAbsence needs
to be requeried, which should also take care of the text
box.
On further reflection, I suspect that it's possible that you
might be able to duck the whole issue by ignoring everything
else you've tried and just using:
Me.sspdays.Requery
instead of the SetFocus, etc.
--
Marsh
MVP [MS Access]
Assumong that employeename is a Text field, the Dcount
should then look more like:
=DCount("*","sicknessabsences","employeename='" & [sickname]
& "' And paid=Forms]![frm x main]![month name] And
absencetype='s' ")
Note that if [month name] is changed while
frmSicknessAbsence is open, you will need to at least
Requery the DCount text box and ony other item that uses
[month name] as a criteria. Actually, looking back at the
form's record source, is see that frmSicknessAbsence needs
to be requeried, which should also take care of the text
box.
On further reflection, I suspect that it's possible that you
might be able to duck the whole issue by ignoring everything
else you've tried and just using:
Me.sspdays.Requery
instead of the SetFocus, etc.
--
Marsh
MVP [MS Access]
Leslie said:You are right - there are two forms from which criteria are taken. [frm x
main] is in fact the mdb's startup form, and has various texboxes the values
of which are use for various process. One such texbox is 'month name', and
this is used as a parameter for the data source of the other form
[frmSicknessAbsence]. It is [frmSicknessAbsence] that has the textboxes that
are not automatically displaying their values. There are no problems with
[frm x main], which is definitely open all the time - including when
[frmSicknessAbsence] is loaded. The non-displaying problem occurs
immediately when [frmSicknessAbsence]is opened - not just if the value of
'month name' on [frm x main] is changed. I would add that 'month name' on
[frm x main] is used by other processes (e.g. as filter for reports) without
any problems.
PayeDoc said:Many thanks for continuing with this!
I now have Count(*) working as you suggest. In fact the original
expression
wasn't returning a blank - it's just that its value didn't display until I
clicked in the field (just like the other textboxes) - derr!!
I have removed the HAVING clause as you suggested. The sql of the query is
now:
SELECT sicknessabsences.employeename, Count(*) AS CountOfAbsenceID,
staffs.[ssp days], [nml hourweek going]*[Hourly rate]/[paydays] AS
[workday
rate], staffs.[nml hourweek going], staffs.[Hourly rate], staffs.paydays
FROM staffs LEFT JOIN sicknessabsences ON staffs.name =
sicknessabsences.employeename
WHERE (((sicknessabsences.absencetype)="W" Or
(sicknessabsences.absencetype)="S" Or (sicknessabsences.absencetype)="L")
AND ((sicknessabsences.paid)=[Forms]![frm x main]![month name])) AND
(((sicknessabsences.employeename)=[Forms]![frmSicknessAbsence]![sickname]))
GROUP BY sicknessabsences.employeename, staffs.[ssp days], [nml hourweek
going]*[Hourly rate]/[paydays], staffs.[nml hourweek going],
staffs.[Hourly
rate], staffs.paydays;
I now have your expression:
=DCount("*","sicknessabsences","employeename='" & [sickname] & "' and
paid=
'" & [month name] & "' and absencetype='s' ")
as data source for the textbox called 'sspdays', but this returns #Name?.