Using macro to type in parameter values

S

sfgiantstmel

Hello,

I have a list of items that I need to pull from a query. The process that I
am trying to anomate is to open the query, where i am prompted to answer a
question called a "parameter value." Once this is typed in and the query is
opened, I do the whole process again for the same query but a different value
in the paramter value.

I am trying to write a macro to anomate this process. I have created a new
macro, and the first action is "openquery," whichI have done. The next step
is when the parameter value box opens up. I need the macro to automatically
type in a string that I want it to enter. Is this possible?

Thank you!!
 
S

Steve Schapel

Sfgiantstmel,

Regarding: "automatically type in a string that I want it to enter" - how is
the macro supposed to "know" what is the value you want it to enter? Where
can we see or find this string?

(Note: Access does not do mind reading!) :)

--
Steve Schapel, Microsoft Access MVP


sfgiantstmel said:
Hello,

I have a list of items that I need to pull from a query. The process that
I
am trying to anomate is to open the query, where i am prompted to answer a
question called a "parameter value." Once this is typed in and the query
is
opened, I do the whole process again for the same query but a different
value
in the paramter value.

I am trying to write a macro to anomate this process. I have created a new
macro, and the first action is "openquery," whichI have done. The next
step
is when the parameter value box opens up. I need the macro to
automatically
type in a string that I want it to enter. Is this possible?



__________ Information from ESET Smart Security, version of virus signature database 4229 (20090709) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
S

sfgiantstmel

I know what the string is - I have about 30 different ones that I continually
have to type in and pull a querie with. I thought that it may be possible to
have write a macro that tells access "open this querie --> type in the
following string --> "my string" and then go on from there. Is this possible?
 
S

Steve Schapel

Sfgiantstmel,

No, it is not possible. There is no way a computer can automatically use
information simply on the basis of "I know what it is". It has to be able
to locate that information somewhere on the computer itself. If "my string"
is just in your head, the macro can not access this. Understand?

--
Steve Schapel, Microsoft Access MVP


sfgiantstmel said:
I know what the string is - I have about 30 different ones that I
continually
have to type in and pull a querie with. I thought that it may be possible
to
have write a macro that tells access "open this querie --> type in the
following string --> "my string" and then go on from there. Is this
possible?




__________ Information from ESET Smart Security, version of virus signature database 4232 (20090710) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
S

sfgiantstmel

Let's say I know that I want to type in 5500 when the "enter parameter" box
comes up. And after this I'm going to type in 6500. And after this
7500...etc. And these numbers are always the same week to week, and I have
about 30 of them. Not only are they in my head but I can put them anywhere
else - in a table, list, excel file, in the macro itself. My goal is to have
this pre-determined list of 30 numbers that never changes, and instead of
having to pull them individually, to do them all at once. The problem resides
in that I don't know how to tell the macro to "go get this number" (wherever
I am storing it).

Thank you again for your help
 
C

Clifford Bass

Hi,

This makes more sense. First thing, put your numbers in a table.
Second thing, you are probably going to have to shift from using Macros which
are pretty much linear to VBA where you can do the looping and whatnot. In
the VBA you will open up the number table as a record set, read each row,
execute the query, perhaps by passing the parameter to the query BEFORE
executing it, execute the query, then read the next number, loop back around,
and so forth until no more rows are found in the recordset.

Now, earlier I said "probably". It may be possible to do what you want
all in one query. It just depends on what you are doing with the query. How
about expanding on why you are running a query thirty times with different
numbers? What does it accomplish?

Clifford Bass
 

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