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

Setting query criteria from a public function

Status
Not open for further replies.

1starr

Programmer
Feb 19, 2002
34
US
I having attempting to get my query to get criteria input from a Public Function in order to create the output for a report. In the Public Function I have it set up like this:
Option Compare Database

Option Explicit

Dim strDom As String

Public Function FindDomain()
FindDomain = strDom

End Function

So what I have done is try to gather the data from FindDomain() and have the quey on look for that data. Something like this:

SELECT [CERT June].Category, Status.Weight, Status.Status, Sum([CERT June].Count) AS SumOfCount, [CERT June].Domain
FROM [CERT June] RIGHT JOIN Status ON [CERT June].Status = Status.Status
GROUP BY [CERT June].Category, Status.Weight, Status.Status, [CERT June].Domain
HAVING ((([CERT June].Domain)=FindDomain()))
ORDER BY [CERT June].Category, Status.Weight;

What am I doing wrong, Please help....
 
The way it looks from your example, FindDomain() is returning an empty string.

Usually you have set the value before you query. For instance you might call setFindDomain("Foo")

Here's modified VBA code:
-----------------------
Dim strDom As String

Public Function setFindDomain(ps as string)
strDom=ps
End Function


Public Function FindDomain()
FindDomain = strDom
End Function
------------------------

Now you run your query and any domain = "Foo" will get picked.
 
Yes, the value of strDom is set when the user enters the form and completes his entries. What I need is for the query to give the values for that strDorm so a new report can be produce with out the user having to enter that strDom data again.
 
What you can do is bring up your commadn window (CTL+G) and type in ?FindDomain()

Do you get any value?
 
Thanks, for your help but all of sudden it started working. I don't know what the bug was cause yesterday I first step thru it and it seem that the flow of data for strDom wasn't flowing correctly and them when I came back to it today, it worked with out a problem. There must had been some kinda bug or it might be because I reboot my system that cause it to work correctly. Again thank you for your assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top