Results 1 to 3 of 3

Thread: Query

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    88

    Query

    How to pass parametar to Access query. when I open query in Access it ask me to enter parametar but I don't know how to pass it from VB

  2. #2
    Hyperactive Member mvrp350's Avatar
    Join Date
    Feb 2001
    Location
    Best, the Netherlands
    Posts
    322
    When you have to add a parameter in a Query in Access it means that not all the information you use to create the query is available. I don't think you're able to pass a parameter with VB (forgive me if I'm wrong)
    I would use the following to solve this problem:
    Remove the missing parameter from your query, or
    create a new table for that parameter and fill it using VB, or
    run the SQL inside VB and add the parameter over there.

    One of the ways to receive that message is to create a query i.e.
    length, width, price/m2.
    Add a calculated field
    area : [length] * [width] and WITHOUT saving use the calculated field to recalculate a new field:
    Total : [area] * [price/m2]

    If you save the query between the calculated fields it works fine

  3. #3
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    No, that's not the way.
    You can pass parameters for a parameter query from VB. You can use the Command object's parameter collection in ADO.

    Assuming the connection string/objects are set up

    Dim objCmd as new ADODB.Command
    Dim objRS asd ADODB.Recordset
    Dim objParam new ADODB.Parameter
    'an example of an ID parameter of type integer
    Set objParam = objCmd.CreateParameter("ID", adInteger, adParamInput)

    'append the parameter to the Command's parameter colletion.
    objCmd.Append objParam
    'execute the command
    set objRS = objCmd.Execute("StoredQueryName")
    VB 6.0, Access, Sql server, Asp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width