function in query trouble

G

Guest

how can i call a function within a query for the 'having' clause of my query.
The variable currently proceeds with "HAVING".. i was trying to trim the
variable to eliminate the word "HAVING" but am having trouble.. i am having
alot of trouble with the syntax of the function call within my query (NOT
embedded). here is my query and here is the function.. thank you.

SELECT tblRefunds.Company, tblRefunds.TaxType, tblRefunds.Date,
tblRfundAmtsToAccts.GLAccountNo, tblRfundAmtsToAccts.Amount
FROM tblRefunds INNER JOIN tblRfundAmtsToAccts ON
tblRefunds.ID=tblRfundAmtsToAccts.ID
WHERE tblRefunds.DeletedRefund=False
GROUP BY tblRefunds.Company, tblRefunds.ID, tblRefunds.Date,
tblRefunds.taxType, tblRfundAmtsToAccts.GLAccountNo,
tblRfundAmtsToAccts.Amount
HAVING GetGlobalCheck()
ORDER BY tblRefunds.TaxType DESC;

Public Function GetGlobalCheck() As String
Stop
'truncate the 'having' reserved word, because is in query
'mySQLCheck = Trim(Left(mySQLCheck, 7))
GetGlobalCheck = Eval(mySQLCheck)
End Function
 
M

M.L. Sco Scofield

Try this for your function:

Public Function GetGlobalCheck() As String

GetGlobalCheck = Mid(Trim(mySQLCheck), 8)

End Function

This assumes that you have a public (or a module level in the same module as
the function) variable named mySQLCheck that contains a valid HAVING clause.

Happy New Year!

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
G

Guest

thanks so much! that did it!

M.L. Sco Scofield said:
Try this for your function:

Public Function GetGlobalCheck() As String

GetGlobalCheck = Mid(Trim(mySQLCheck), 8)

End Function

This assumes that you have a public (or a module level in the same module as
the function) variable named mySQLCheck that contains a valid HAVING clause.

Happy New Year!

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
M

M.L. Sco Scofield

You're most welcome.

Happy New Year!

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top