Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookup instead of sql 1

Status
Not open for further replies.

kennetha

Programmer
Sep 10, 2003
105
MT
Hi all,

I have created the below on a form basically to open it hidden, check if there is any data (like if dcount()>0 and then continue or stop the code when necessary. My question. Is there any other way to accoplish the task with a simple Dlookup or an Sql code?

Here's the sql;

SELECT t.idcode, t.dfrom, t.dto FROM t WHERE (((Forms!vv!txty) Between [dfrom] And [dto])) GROUP BY t.idcode, t.dfrom, t.dto HAVING (((t.idcode)="101z"));

Thanks in advance
Kenneth
 
You may try something like this:
Code:
If IsNull(DLookUp("idcode", "t", "idcode='101z' AND Forms!vv!txty Between dfrom And dto")) Then
  'no data
Else
  'process data
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV,

It worked fine and defitely better than opening and closing forms.

How can i change "idcode='101z'..." if it is to come from an edit box (txtidcode) in Forms!vv!?

If IsNull(DLookUp("idcode", "t", "idcode='" & Forms!vv!txtidcode AND Forms!vv!txty Between dfrom And dto")) then
...

Is it correct

Regards
Kenenth
 
If IsNull(DLookUp("idcode", "t", "idcode=Forms!vv!txtidcode AND Forms!vv!txty Between dfrom And dto")) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top