Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Congratulations on a brilliant idea and a great site..."

Geography

Where in the world do Tek-Tips members come from?

Can param'tr be passed in VBA (opening a report driven by param qry)

Paul7905 (MIS)
3 Nov 00 3:36
Have a report that is driven by a parameter query.

I would like to print it from a command button on a form but don't want the user to have to key in the parameter because it is a nonsensical number that the underlying code already knows.

Is it possible to pass the parameter to the Query that drives the report from VBA code?

(looking at the OpenReport "help" it appears that something can be passed as sql?    does this mean that i can code the same sql that is in the parameter query here ?)

something like the following ? note, the actual value i need to pass to the query is in a global string defined as "SAVEKEY"......  it has the argument that the query needs to match on ~  i figured i could pass it as follows but it does not work ~ !

DoCmd.OpenReport stDocName, acPreview, , [ProductInfo.KEY2] = SAVEKEY


The "where" statement in the parameter query that underlies the report reads :

Where (([ProductInfo.KEY2] = [KEY]));

KEY is the name of the parameter ~     

Hope it is possible to do something like this ~  driving me nuts !  

BTW, thanks in advance !      



 
 
kathryn (Programmer)
3 Nov 00 6:25
Paul,

This really isn't too difficult.  Does the underlying code know the value when you press the button?  If so, my first thought (I will point out that it's only 7:20 am here1) is that you put a hidden textbox (visible = false) on the form with the value of the textbox set to the variable.  This can be done a few ways.

Then your query would have a criteria that referred to the field on the form.  Something like:

              Forms![myForm]![txtName]

How does that sound?

Kathryn
 
 
 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close