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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a simple Function help

Status
Not open for further replies.

proggy

Programmer
Apr 21, 2002
46
US
Hello there..
I have a function which has to run query1 if a value from a table field is <> zero else has to run query2
so..
If count <>0
then run q1
else run q2...
how can i refer to a value in a table in the VBA module?? I tried tables! tablename.fieldname, but it says object required..
any help is really appreciated..
thanks,
 
Hi!

Use DLookUp:

DLookUp(&quot;YourField&quot;, &quot;YourTable&quot;, &quot;YourCriteria&quot;)

hth
Jeff Bridgham
bridgham@purdue.edu
 
thanks bud..
It's working..
thanks a lott..
 
What Jeff said.

If you had a table called Acct, with a totBal field, it might look like this:

If DLookUp(&quot;totBal&quot;, &quot;Acct&quot;, &quot;CustID = 1234&quot;) <> 0 Then
DoCmd.OpenQuery &quot;q1&quot;
Else
DoCmd.OpenQuery &quot;q2&quot;
End If
Jim Lunde
compugeeks@hotmail.com
We all agree your theory is crazy, but is it crazy enough?
 
Hi folks.. thanks..
I have another question if u can bear with me..

I have a query1 which has to search a field from a table and return the records which match a user input ..
first it has to take a user input and search the field and *if records exist then return them
*if no records then return all records,
*if user enters nothing then also return all records..

Now the problem is..a second query (query2) which takes an other input has to search from these outputed records or query 1 and do the same thing again...
like this user enters 2 more inputs..
I used inner join and did it.. calling the query 1 in query2 and so on.. but it is darn slow..
some suggested to use exists..but i am lost..
can anyone..please suggest me how to do this using SQL and VBA..
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top