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

Call public function from SQL ?

Status
Not open for further replies.

ZABADAK

Programmer
Feb 24, 2005
39
US
I thought it was possibnle to call a public function from an SQL query but I am getting 'variable not defined'. The error is in the call of Function ED toward the end. Here is my SQL:

strSQL = "SELECT [SSR_#], [TASK_#], [TASK_DESCRIPTION], [PRIORITY], " & _
" [ASN_FROM] As PRIORITY_DATE, " & _
" ED([PRO_FROM],[CLS_FROM],[CAN_FROM]) As CompDate, " & _
" DATEDIFF('d',[ASN_FROM],ED([PRO_FROM],[CLS_FROM],[CAN_FROM])) " & _
" As CompDays " & _
" FROM tblSSRData " & _
" WHERE (NZ(PRO_FROM) <> 0 OR NZ(CLS_FROM) <> 0 OR " & _
" NZ(CAN_FROM) <> 0) " & _
" AND #" & ED(PRO_FROM, CLS_FROM, CAN_FROM) & "# BETWEEN " & _
" #" & SelFrom() & "# AND #" & SelTo() & "#
 
Don't need the extra #
Code:
 " AND [b]#[/b]" & ED(PRO_FROM, CLS_FROM, CAN_FROM) & "[b]#[/b] BETWEEN " & _

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Thanks a million, I'll give it a try. Funnily enough, I did not originally have those there but then I tought they were needed, so I added them.
 
I'm still getting 'variable not defined' for the first parameter of the ED function, I tried switching the order of the parameters - same thing. Those variables are columns of the table tblSSRData in the FROM clause. They are deined as variant in the function since they can be Null.
 
Replace this:
" AND #" & ED(PRO_FROM, CLS_FROM, CAN_FROM) & "# BETWEEN " & _
By this:
" AND ED([PRO_FROM],[CLS_FROM],[CAN_FROM]) BETWEEN " & _

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top