PC Review


Reply
Thread Tools Rate Thread

DLOOKUP command not working

 
 
mot98@yahoo.com
Guest
Posts: n/a
 
      13th Nov 2006
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.

 
Reply With Quote
 
 
 
 
kingston via AccessMonster.com
Guest
Posts: n/a
 
      13th Nov 2006
If you just want the number of records, try DCount():

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

(E-Mail Removed) wrote:
>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.


--
Message posted via http://www.accessmonster.com

 
Reply With Quote
 
mot98@yahoo.com
Guest
Posts: n/a
 
      13th Nov 2006
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.

kingston via AccessMonster.com wrote:
> If you just want the number of records, try DCount():
>
> If DCount("*","Get_All2") = 0 then
> Call Do_Nothing
> End If
>
> (E-Mail Removed) wrote:
> >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.

>
> --
> Message posted via http://www.accessmonster.com


 
Reply With Quote
 
=?Utf-8?B?U2hhcmtieXRl?=
Guest
Posts: n/a
 
      13th Nov 2006
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




"(E-Mail Removed)" wrote:

> 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.
>
>

 
Reply With Quote
 
kingston via AccessMonster.com
Guest
Posts: n/a
 
      13th Nov 2006
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.


(E-Mail Removed) wrote:
>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]
>> >I have double checked the table the query is pulling from, and there
>> >are no records.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200611/1

 
Reply With Quote
 
mot98@yahoo.com
Guest
Posts: n/a
 
      13th Nov 2006
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

Sharkbyte wrote:
> 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
>
>
>
>
> "(E-Mail Removed)" wrote:
>
> > 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.
> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DLookup not working Design by Sue Microsoft Access Form Coding 4 11th Jan 2008 01:38 AM
Dlookup not working SHIPP Microsoft Access VBA Modules 1 11th Dec 2007 05:11 PM
Simplest way of using ADO Recordset to replace DLookup command J Microsoft Access 4 13th Oct 2006 03:43 PM
Help with DLookUp Command =?Utf-8?B?U3RvbmV3YWxs?= Microsoft Access Forms 3 22nd Apr 2005 05:25 PM
dlookup command Jason Frazer Microsoft Access Reports 0 14th Nov 2003 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 PM.