Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1. Guest ji, please consider donating today!
      Become a Supporter    ::   Make a Contribution   
    Monthly Recurring Target: $300 :: Achieved: $95

Dynamic query parameters

Discussion in 'Information Technology' started by Bob, Nov 5, 2005.

  1. Bob

    Bob
    Expand Collapse
    Guest

    Got controls with a Rowsource using a select statement, the where clause of
    the select statement should use a variable existing in code.
    Whats the syntax for writing this
    Quick sample:

    Dim Myvar as string
    Myvar = "abcd"
    Say the variable setting above was public in scope and declared well before
    the form using it is called.
    select * from mytable where myfield = "abcd" what I would think to be the
    final result sql statement

    What should I write in the Rowsource of the control? I dont want parameter
    question boxes to pop up. I just want the control to gran the variable and
    use it automatically.


    Thanks for any help

    Bob
     
  2. Loading...

    Similar Threads Forum Date
    India India's family dynamic undergoing a change Breaking News Feb 7, 2011
    Dynamic Morality Essays on Sikhism Jul 21, 2004
    Query about Jhatka Meat by Shooting in Head Sikh Sikhi Sikhism Aug 26, 2011
    Who is a sikh? A non sikh friend's query!! Sikh Sikhi Sikhism Apr 30, 2010
    General Query Hard Talk Sep 4, 2008

  3. Wayne Morgan

    Wayne Morgan
    Expand Collapse
    Guest

    You could rewrite the Row Source using code.

    Me.MyControl.RowSource = "select * from mytable where myfield = """ & MyVar
    & """"

    This will concatenate in the value of MyVar and place double quotes around
    it.

    You could also place the value of the variable in a table created just for
    this purpose then the SQL statement could find it using a DLookup function.

    --
    Wayne Morgan
    MS Access MVP


    "Bob" <bdufour@sgiims.com> wrote in message
    news:%23vJPHaW4FHA.2640@TK2MSFTNGP09.phx.gbl...
    > Got controls with a Rowsource using a select statement, the where clause
    > of the select statement should use a variable existing in code.
    > Whats the syntax for writing this
    > Quick sample:
    >
    > Dim Myvar as string
    > Myvar = "abcd"
    > Say the variable setting above was public in scope and declared well
    > before the form using it is called.
    > select * from mytable where myfield = "abcd" what I would think to be the
    > final result sql statement
    >
    > What should I write in the Rowsource of the control? I dont want parameter
    > question boxes to pop up. I just want the control to gran the variable and
    > use it automatically.
    >
    >
    > Thanks for any help
    >
    > Bob
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page