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

Syntax for a DLOOKUP as the criteria of another DLOOKUP?

Status
Not open for further replies.

BoydW

Technical User
Jun 7, 2001
4
0
0
US
Can a DLOOKUP function which returns a string be the criteria for a DLOOKUP? Here's my example I'm working with now:

-Text box
Name: OPO_SSN
Control Source: =DLookUp("[SSN]","NTT Staff","[Dept]='OPO'")

-Another Text box
Control Source: =DLookUp(&quot; [Type]&quot;,&quot;Transactions&quot;,&quot; Date1 >= [StartDate] and Date1<=[EndDate] and OPO_SSN=[SSN]&quot;)

I'd like to replace the criteria in the second text box (OPO_SSN=[SSN) with the DLOOKUP formula in the first text box to consolidate the calculation. I'd surely appreciate any guidance in this. Thanks!

-Boyd
 
Try something like this on the OnOpen event of the form (let's say the name of your second text box is txtType):

==========
Dim strSSN As String, strDLU As String

strSSN = DLookUp(&quot;SSN&quot;,&quot;NTT Staff&quot;,&quot;Dept='OPO'&quot;)
strDLU = DLookUp(&quot;Type&quot;,&quot;Transactions&quot;,&quot;Date1 >= StartDate and Date1 <= EndDate and OPO_SSN = '&quot; & strSSN & &quot;'&quot;)

Me.txtType = strDLU
========== Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top