dlookup

A

AccessMan

I am using two successive DLookUp statements against the same table with
different criteria after a form button is clicked. Sometimes, the second
statement generates an "invalid use of NULL" error, and I can't figure out
why. It is certainly not a data issue. Both calls involve valid criteria.
Has anybody run into a timing issue? Could the first DLookUp have not closed
down its access to the table before the second DLookUp starts? If I comment
out either one of the DLookUp statements the error does not arise.

Thanks!!!
 
M

Mike Painter

AccessMan said:
I am using two successive DLookUp statements against the same table
with different criteria after a form button is clicked. Sometimes,
the second statement generates an "invalid use of NULL" error, and I
can't figure out why. It is certainly not a data issue. Both calls
involve valid criteria. Has anybody run into a timing issue? Could
the first DLookUp have not closed down its access to the table before
the second DLookUp starts? If I comment out either one of the
DLookUp statements the error does not arise.

Thanks!!!

Try a Do Events between the two.
 
A

AccessMan

Mike - I'm not familiar with that statement, and help was not helpful. Could
I ask for the exact syntax please?
 
J

J_Goddard via AccessMonster.com

The problem might not be the DLookup statement itself, but what you are doing
with the results. Are you sure that both DLookup statements return a value
(i.e. there is a record that meets the criteria), even though though the
criteria itself is valid? If the DLookup returns a Null, you will often get
this error unless you handle a Null using (for example) the Nz function:

MyVariable = Nz(Dlookup(...), 0 ) for numeric data.

You should also verify that the Field you are querying using the DLookup does
not contain Null.

John
 
M

Mike Painter

AccessMan said:
Mike - I'm not familiar with that statement, and help was not
helpful. Could I ask for the exact syntax please?

It's all one word and it just lets the system catch up with things before
going on.
99.9% of teh time event driven ssoftware is a good thing but sometimes one
event will start before an earlier needed one gets finished.

some code ges here
DoEvents
some more code goes here
 

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

DLookup 2
Using Max or DMax in DLookUp criteria? 1
Dlookup in ControlSource 2
DLookUp 7
Dlookup error 4
multiple issues with access form 1
that didn't work 1
DLookup 4

Top