No, your syntax isn't correct. What you've got will look for the literal
string fOSUserName(), as opposed to the value returned by the function call.
CurrCount = DCount("[CSE Case#]", "[tbl_Main]", _
"[Task'd CSO] = '" & fOSUserName() & "'")
Exagerated for clarity, that's
CurrCount = DCount("[CSE Case#]", "[tbl_Main]", _
"[Task'd CSO] = ' " & fOSUserName() & " ' ")
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Iram said:
Beautiful, however I forgot to mention that the table is shared by many
folks. So I changed the part where you talked about CurrCount to this
below.
However when the refresh occurs no beep sounds. Do I have the syntax right
on
the above statement?
CurrCount = DCount("[CSE Case#]", "[tbl_Main]", "[Task'd CSO] =
'fOSUserName()'")
There are spaces in the field names with apostraphies, and pound symbols,
and I am using the fOSUserName() module that looks to see who is logged
into
the computer. Basically it's saying count CSE Case Numbers in table
tbl_Main
where the Task'd person is me (the person logged in). Can you help me fix
the
above statement?
Iram
John W. Vinson said:
Private Sub Form_Timer()
Me.Requery
End Sub
The Timer Interval is 6000
How do I do what you said, "Have a Static variable set to the count
every
time the routine runs; beep if it's changed."?
Like I said I have a Text Box in the form header that counts all the
records
in the detail section.
=Count([CaseNumber])
And in actuality I need the Beep to only occur when the number in this
field
goes up not down.
Change the timer event to check:
Private Sub Form_Timer()
Static iCount As Integer
Dim CurrCount As Integer
Me.Requery
CurrCount = dcount("[CaseNumber]", "[tablename]")
If CurrCount > iCount Then
Beep
iCount = CurrCount
End If
End Sub
This will allocate a "sticky" variable iCount, which will hold its value
over
time as the Timer event gets called repeatedly. Each time it will count
the
number of non-null CaseNumbers in the table tablename - edit this to the
name
of an appropriate table or query. If that number is greater than the
value
remembered from last time in iCount, it will beep and store the new
count.