dlookup problem

  • Thread starter Thread starter Naz
  • Start date Start date
N

Naz

Hi

I have a textbox on a form that should pull out the number of employees for
a manager from a query based on an unbound field on the form called userid. I
have used the formula

=IIf([Myself]=-1,DLookUp("[countofemps]","qry_HP_Keystatistics","[reports_to] = '" & [userid] & "'"),"-")

but it keeps showing "error", anyone know where i am going wrong?

All help is greatly appreciated
 
but it keeps showing "error", anyone know where i am going wrong?

If Userid is a Number datatype field, lose the quote delimiters:

=IIf([Myself]=-1,DLookUp("[countofemps]","qry_HP_Keystatistics","[reports_to]
= " & [userid]),"-")

Actually if it's a count you want, you might want to use a DCount() function
to count them, rather than calling some totals query - cut out the middleman.
 
Hi

1) The error message i get is #error
2) [Userid] is a simple unbound text box, where a managers name is input
3) [Userid] is unbound so i don't know, but i guess it would be text
 
Hi

I have a textbox on a form that should pull out the number of employees for
a manager from a query based on an unbound field on the form called userid. I
have used the formula

=IIf([Myself]=-1,DLookUp("[countofemps]","qry_HP_Keystatistics","[reports_to] = '" & [userid] & "'"),"-")

but it keeps showing "error", anyone know where i am going wrong?

All help is greatly appreciated

What is the datatype of [reports_to]? If it's text, is it a Lookup Field (in
which case it really isn't text but rather a concealed Number ID)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

multiple criteria in dlookup 6
DLookup in CrossTabQuery form 6
Dlookup Question 5
Trying to use DLookup 3
Using Dlookup in form - New to Access 3
DLookUp Format 4
Auto update on combo form field 1
Dlookup problem 6

Back
Top