DLOOKUP command not working

M

mot98

Hi All,

I am trying to use the DLOOKUP command in my VBA code.

Basically I want it to lookup my query and if there are no records to
skip the rest of my code.

Here is what I am using:
If dlookup(1, "Get_All2") < 0 Then
Call Do_Nothing
End If


But it is not working....my code is still being run.

I have double checked the table the query is pulling from, and there
are no records.
 
K

kingston via AccessMonster.com

If you just want the number of records, try DCount():

If DCount("*","Get_All2") = 0 then
Call Do_Nothing
End If
 
M

mot98

I tried that code as well....and it still does not work.

After the DCOUNT command, I am using a ADO connection and using the
RS.MOVEFIRST command.

I keep getting the "No Current Record" error..Which I understand,
becaue the query is empty.

For some reason...it is not ignoring the code.
 
G

Guest

You may be seeing that Access is evaluating a Null different than being '< 0'.

Try this:

If isnull(dlookup(1, "Get_All2")) Then
Call Do_Nothing
Else
End If

Sharkbyte
 
K

kingston via AccessMonster.com

In the programming window, go to the bottom pane and enter:

?DCount("*","Get_All2")

Does it give you an error or a valid answer? If it gives you an error, then
there's something wrong with the dataset Get_All2. If it gives you an answer,
then the problem lies elsewhere.


I tried that code as well....and it still does not work.

After the DCOUNT command, I am using a ADO connection and using the
RS.MOVEFIRST command.

I keep getting the "No Current Record" error..Which I understand,
becaue the query is empty.

For some reason...it is not ignoring the code.
If you just want the number of records, try DCount():
[quoted text clipped - 18 lines]
 
M

mot98

Hi Sharkbyte,

I finally got it working with your code. I was having issues, but then
created a seperate Sub to check dlookup value and it worked great.

Thanks,

Mike
 

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


Top