We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

How to prompt user for parm value from module

xhat
xhat asked
on
Medium Priority
230 Views
Last Modified: 2011-10-03
I've found stuff all over the Internet that hits around my question, but nothing that directly addresses the issue.  I have a module that I'm using to output a text file.  Part of the data that is output is going to come from a parameter query I've built.  My goal is to be able to simply run the module and be prompted for the parameter.  Most of what I've read deals with getting the parameter value from a form, but in this case, a form is neither necessary nor desired.  The module and db will only ever be used/accessed by myself and my boss.  I've fiddled with the code (both DAO and ADO methods) to open the query and pass it the parameter value, but I keep running into errors.  The primary one being "Object variable or With Block variable not set."  Below is the current state of my code.

    Dim cmd As New ADODB.Command
    Dim rst As New ADODB.Recordset
    Dim param As ADODB.Parameter
    'Dim qry As DAO.QueryDef
   ' Dim db As DAO.Database
    'Dim parm As DAO.Parameter
    'Dim rst As DAO.Recordset


    Set cmd.ActiveConnection = CurrentProject.Connection
    cmd.CommandText = "GET_TMFR_DATA"      'name of param query
    For Each param In cmd.Parameters
        param.Value = Eval(param.Name)
    Next param
    Set rst = cmd.Execute(cmd.CommandText, param)

    'Set qry = db.QueryDefs("GET_TMFR_DATA")
    'qry.Parameters(0) = "FS06"
    'Set rst = qry.OpenRecordset

The lines that are commented out are the DAO method which yields the error "Object variable or With Block variable not set.
The ADO method yields the error "Invalid SQL statement; expected DELETE, INSERT, PROCEDURE, SELECT, or UPDATE statement"
Comment
Watch Question

Commented:
use the Inputbox

YourParm =inputbox("what is the value you want to enter")

then YourParm have the value you want , and you can use it in your code.

jaffer

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Of course! How obvious.  Thanks for showing me the forest. The trees were in the way.

Commented:
it must have been foggy too :o)

you are welcome,
thanks for the points and the grade

jaffer
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.