Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Define/passing varibles in excel to Sql Query

  • 01-04-2008 11:49AM
    #1
    Registered Users, Registered Users 2 Posts: 221 ✭✭


    Hi All,

    I'm pretty much totally new to excel . I'm working on a sheet, which needs to draw data from an sql server DB. I need to allow the user to enter a date into a field and use this in the query. I have a sample query in which I can see that in the query the variable is shown as '<variablename>' and in the sheet on another sheet theres "set variblename = " and a reference to the field where the user enters variable value.

    How do i define a variable like above so excel recognises what I’m passing

    Thanks in advance

    - Elfman


Comments

  • Registered Users, Registered Users 2 Posts: 901 ✭✭✭EL_Loco


    are you using VBA for this in a macro, or are you trying to use the datasource functions in the excel GUI?

    in VBA to get the value of a cell and assign it:
    dim sVar as string
    
    sVar = cells(1,1).value
    
    'where 1,1 is the co-ordinate of the cell. row, column
    
    

    this link may help also:

    http://www.oreilly.com/catalog/integratingea/chapter/ch03.pdf


  • Registered Users, Registered Users 2 Posts: 221 ✭✭Elfman


    Yeah I'm trying to avoid using vba if i can


  • Registered Users, Registered Users 2 Posts: 901 ✭✭✭EL_Loco


    just went to try a database query through the GUI and it's not installed. have to go find the disc. :( why does it do that, it's a real pain, I did a "full" install initially too.


Advertisement