Send Object Macro, Need Help!!

  • Thread starter HOW DO I CREATE A SEARCH FORM????
  • Start date
H

HOW DO I CREATE A SEARCH FORM????

hi,

I've created a send object macro that runs everytime i open the main form in
my database. THis macro is setup to email me a query. WHat i want is for it
to only email me when there are records in the query. The way i have it set
up now, it emails me whether or not there are records in the query.

thanks for looking!
 
T

Tom Wickerath

You won't be able to achieve this result using a macro. It's time to start
learning how to program using VBA (Visual Basic for Applications) code. Here
is a general outline of the steps required:

1.) Declare database and recordset variables
2.) Set database variable to currentdb, for example:
3.) Set recordset variable to source query
4.) Use an IF...THEN test to test for recordcount
ie. If rs.recordcount > 0 Then
DoCmd.SendObject........
End If

5.) Close the recordset and database variables and then set each = nothing
6.) Don't forget to include error handling code.

If you are interested in pursuing this idea, then post back and I can
provide a more complete sample. If, on the other hand, you are not willing to
venture beyond macros, then you'll have to live with the current situation.

If my answer has helped you, please answer yes to the question that reads
"Did this post answer the question?" at the bottom of the message thread.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

hi,

I've created a send object macro that runs everytime i open the main form in
my database. THis macro is setup to email me a query. WHat i want is for it
to only email me when there are records in the query. The way i have it set
up now, it emails me whether or not there are records in the query.

thanks for looking!
 
S

Steve Schapel

Tom said:
You won't be able to achieve this result using a macro.

Eh? What? Did you read the original poster's post yesterday? To quote
them: "i got it to work".
 
T

Tom Wickerath

Steve,

I had not noticed the follow-on thread, until you just mentioned it.

Okay, I was wrong....one can use DCount in the conditions for a macro. I'm
just so conditioned to avoid using domain aggregrate functions that I
overlooked that possibility.

Tom
_____________________________________
 

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