Macros

  • Thread starter Thread starter Emma
  • Start date Start date
E

Emma

I have a list of questions about a macro I'm trying to design
First how do I get the macro to run when the form opens, ie a msg box
appears when the form is first openned
 
I guess I should be clearer. I opened the form in design view and went to the
Event Tab in the property sheet and onLoad I entered the Macro name. But when
I openned the form nothing happened. The Macro is supposed to make a msg box
pop up.
 
Right click on the form (not one one of the boxes on top of the form, the
form itself)

Select On Load and click the ... that shows up.

enter your code.
 
Did you enter

DoCmd.Run Macro "macroname"

Emma said:
I guess I should be clearer. I opened the form in design view and went to the
Event Tab in the property sheet and onLoad I entered the Macro name. But when
I openned the form nothing happened. The Macro is supposed to make a msg box
pop up.
 
Ok that fixed my first question. Now that the msg comes up here's my 2nd
question

2. Is it possible for the macro to go through a table of clients or will it
only do the first client openned in the form. I have a report of all the
clients that meet the condition which opens up. But I would like the macro to
say ok this client doesn't meet the condition, what about the next client in
the table? Or do I need to use VB?
 
What I mean is I don't want the user to have to go through all the records by
clicking the next button and having the macro attached to that.
I would just like the macro to scan through all the clients and come up with
yes there are clients that are true, or no if there are none? Is this
possible?
 
Macros don't "go through" tables. Queries process all Records in their data
source. Why would you want to try to jump through hoops to make a Macro do
something that a Query is designed and intended to do?

You haven't stated the condition you wanted to test in each Record, so I
can't be more specific. In the Query Builder, add the Table of interest to
you, drag down the Fields of interest, and in the Criteria line, specify the
Criteria. That, done correctly, will retrieve just the Records that satisfy
the Criteria you specify.

You can use that Query as the RecordSource of a Form or Report, both of
which you mention in your question. Or, as you mention here, you can go to
View | Totals, specify Count for the Record identifier, and that will give
you the value to answer the question you asked here -- are there any clients
for which the condition is true.

Larry Linson
Microsoft Office Access MVP
 
Hi Larry,

Thanks for the design insight. I have created a query which returns the
correct records which meet the 2 criteria. Now I would like the query to run
when the form is openned. If the query returns a blank datasheet then nothing
happens but if the datasheet has data I would like the report to pop up. Is
this possible? I'm lost as to what to do next.

Thanks Emma
 
I created a macro which oopens the query in print preview then opens the
report if
the QUERY IS NOT NULL. It seems to be working
 

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

Back
Top