running SQL in VBA with parameters

RT

Registered User.
Local time
Today, 08:16
Joined
May 30, 2002
Messages
10
I want to run an append query with parameters. I believe this can only be done from within VBA by explicitly writing the SQL (as I cannot pass a parameter into an access parameter query using VBA code). Is the best way to do this using the 'DoCmd.RunSQL' syntax, and if so, how do I refer to a variable within the SQL code string?

Cheers

Rich
 
You can use a module function to pass global variables into an SQL string. Because VBA and SQL are different languages, they cannot communicate 'directly'.

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=29755

However, why can't you use a popup form and avoid the parameter entirely? Can you make a field on a form to put in whatever variable it is you want, then refer to that form when you run your append query? Maybe I'm misunderstanding the question.
 
I cannot do that because I want to run the query multiple times for the same input to append the same information repeatedly and I only want the user to enter how many times to run the query.

Thanks

Rich
 
I don't understand your structure

Please give a brief example of what you're trying to do. Why would you input the exact same data repeatedly?
 
I'm constructing a label report that can print a certain number of labels (given by the user) for a certain client, or clients. I saw a way of doing this by appending the address for those clients into an emptied table however many times they were needed.

After rereading your previous post, I think I misunderstood, it may be possible to use a form and clear the text fields in that form until there are no more clients wanted, then close the form. Only thing is, the user would have to specify how many clients they wanted labels for.

Hope this is clearer.

Rich
 

Users who are viewing this thread

Back
Top Bottom