Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi,
i'm trying to create parameters within my macro, but i've not been able to find the syntax to do so ... in an Osborne publication i read that you should use the 'runsql' action but that's all it said
of all the valid keywords that could be used in the sql statement for a runsql, 'PROCEDURE' seemed to be the only viable option. but i just can't nail the syntax.
or am i completely of base ...
help please!!!
thanks

Hi AC
Maybe I'm missing the point, but I think your question is unanswerable as it stands.
What specifically are you trying to achieve? Create parameters... for what? Use SQL... on what? ... to retrieve what?
Maybe someone else can guess what you mean, but otherwise I'd say post back some more info, and you may get more help!
Cheers
Tom

o.k. Tom i'll try again,
i'm using access 2002, and i'm trying to buid a macro that will run several queries that i've created. i know how to do that.
what i need to know is how the user can enter the date span (those are the parameters) into the macro.
i read in a manual that to use parameters with macros, you should use the runsql action. but that's all i know. so my question is, the runsql action and what?
is that any clearer?
thanks

Ah! I see. Hmm, the best method is going to depend on exactly what you want to do. How many queries the date affects, for example.
If the date only affects one query, then you can do this:
Write a short function which asks the user for a date. Something like:
Function DateGetter() As Date
Dim myDate As Variant
Do Until IsDate(myDate) = True
myDate = InputBox("What date would
you like?", "Date", "dd/mm/yy")
Loop
DateGetter = myDate
End Function(The reason for the loop is because if you cancel the input, then the type of variable is not 'Date' which could give you problems downstream)
Then, in the criteria for your query, right-click and use "Build" - Functions, Databasename, Module name, "DateGetter". Then every time the query runs, it will ask for a date. So, you can use the same function to return a start and end date. (Or duplicate the function, so the box actually specifies which its asking for)
HOWEVER - if your subsequent queries need to know that date too, then I would SQL it. I'm not 100% sure its the best method, but I don't know a better one (and it saves being asked the dates seven times!). Getting this right is easier than it sounds, but it can be a bit of a faff, because the strings can get a bit unwieldy.
Let me know if you need to learn how to do that, and I'll get in touch.
Good luck
Tom

thanks.
yes, that's what i need (the SQL) ... i have three queries running on the same dates ... so i'm currently getting prompted for the date for each query.
:-)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |