Returning query results to form

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Help. I'm relatively new to developing with Access and
need to make my form respond one way or the other based
on the results of a query.

I'm running a macro when a button is pressed that runs
the query. If a record is found, I need my form to
display one message. If a record is not found, I need a
different message displayed.

How can I pass the True/False results of the query back
to my form? Or...am I barking up the wrong tree? Should
this be a module with an IsNull function?

Please respond via E-Mail. Thanx.
 
Tim,

I think you might need to provide some further information, maybe with
examples, regarding what you are doing, before anyone will be able to
give any specific help. A query doesn't have True/False results, at
least not unless you refer to a particular field in a specific record of
the query's result set. And normally it only makes sense to run an
action query (Append, Update, Make-Table, etc) with a macro. So I am
struggling to understand your question.
 
Alright...here's more information. I'm creating a form to
search the "Do Not Call" list. I've imported the DNC list
into a table and I've created a form and a query so that,
in the form, I can enter the phone number I want to call
and use the query to search the table.

The form and the query work. If the number is on the
list, it is displayed in a query result window. If it
does not exist, I get an empty query result window. What
I am trying to accomplish is go then return to my form and
display a message window letting the user know whether the
number was found our not.

I hope that is enough info for someone to give me some
direction. Thanx.
 
Tim,

Using the same event that you are presently using to do your "search"
(which I presume may be the Click event of a Command Button on your
form, or the AfterUpdate event of the textbox where you enter the phone
number to look for, or some such), you could use code like this...

If DCount("*","NameOfYourQuery")=0 Then
MsgBox "Number not found in DNC list"
Else
DoCmd.OpenForm "QueryResultForm"
End If
 
Back
Top