-----Original Message-----
Hello again,
You're clearly making a lot of progress in the month since last we spoke.
Your comment to Wayne ... do I gather the problem is now solved?
I confess I wasn't entirely happy with my reply to you, but I was also
uncomfortable just to leave the only suggestion as "m = 0" instead of
IsNull, since I could not see how that delivers the error message you
report.
But then neither would my explanation - or any other interpretation of the
code as posted.
One way to get the reported error is
MsgBox Null
but with m defined as Integer, that can't be the route you've found.
If you are now saying that the function used was DLookup and not DCount,
then the error you are getting is if/when the DLookup returns Null and the
assignment into m - an integer variable - fails.
If you are simply trying to determine if a specific employee code exists,
you could manage without a variable:
Function EmployeeId_on_file(empId as Long) As Boolean
EmployeeId_on_file = Not
IsNull(DLookup("employeeID","Employee","[EmployeeID] ="&CStr(empId)))
End Function
CD
hi chadlon ;
m.empid cannot be null , i mean the code will take value
of m.empid and search in another recordset to know whether
this employee has any record their ( old ) , or not ( new
employee)
i remember your smart idea , what do you advice now ?
-----Original Message-----
While I agree with the previous two responses, it is
not
clear from your msg
where the problem is.
If for example the Me.EmpId is null, then you'll fail
on
the DCount
statement and not later.
In summary, then
(a) since DCount returns 0 and not null, m can
correctly
be defined as
Integer, and so an IsNull test is inappropriate.
(b) if there is a chance that Me.EmpId is null, you should protect the
DCount statement.
Your code could read:
dim m as Integer
if IsNull(Me.EmpId) Then
m = 0
else
m=DCount("employeeID","Employee","[EmployeeID] ="&ME.EMPID)
endif
if m = 0 then
'do nothing
else
msgbox m
end if
CD
suppose i have button on a form , this button has
code
to
count records of filterd query ,
i but like this
dim m as integer
m=dcount("employeeID","Employee","[EmployeeID] ="&ME.EMPID)
if isnull(m) then
'do nothing
else
msgbox m
end if
this works perfectly , but when there is no record , it
should be do nothing , but actually it stopped teh code
sending message that " invalid use of null "
.
.