SQL from VB

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Woodies_46@hotmail.com

    SQL from VB

    Hi all,

    Is it possible to refresh the SQL of a query in access using VB. The
    code i already have takes the text from text boxs on my form then
    writes it to a varible called strSQL and turns it into a SQL statment,
    that works fine but its just getting the VB to write that String to the

    queries SQL..


    Thanks
    Nathan

  • Tom van Stiphout

    #2
    Re: SQL from VB

    On 28 Mar 2006 21:14:51 -0800, Woodies_46@hotm ail.com wrote:

    Yes. Populate the SQL property of an existing query with code like
    this:
    CurrentDB.Query defs("SomeQuery ").SQL = strSQL

    -Tom.

    [color=blue]
    >Hi all,
    >
    >Is it possible to refresh the SQL of a query in access using VB. The
    >code i already have takes the text from text boxs on my form then
    >writes it to a varible called strSQL and turns it into a SQL statment,
    >that works fine but its just getting the VB to write that String to the
    >
    >queries SQL..
    >
    >
    >Thanks
    >Nathan[/color]

    Comment

    • Woodies_46@hotmail.com

      #3
      Re: SQL from VB

      Coolness thanks for that, but i think what i'm trying to do is a bit
      more complicated.

      What I have is a form with a subform on it, that subform is linked to a
      query, and what I'd like to happen is when the user fills in the text
      boxs which are optional.Have a peice of code run through all the text
      boxs check if they have a value then take there control name and place
      it in the SQL sting, I have got this part to work fine the next part is
      where i'm lost. I tried the code u gave me which puts the SQL in the
      Query(which is good) but when it runs it turns the first row of the
      query in to expr1 which in turn dosn't link with my subform..

      Thanks
      Nathan

      Comment

      • Tom van Stiphout

        #4
        Re: SQL from VB

        On 28 Mar 2006 21:43:11 -0800, Woodies_46@hotm ail.com wrote:

        That's because your SQL is not yet perfect. Create a perfect query in
        query design view, and observe that the expr1 problem has gone away.
        Then compare its sql statement to the one you were creating so far.

        -Tom.
        [color=blue]
        >Coolness thanks for that, but i think what i'm trying to do is a bit
        >more complicated.
        >
        >What I have is a form with a subform on it, that subform is linked to a
        >query, and what I'd like to happen is when the user fills in the text
        >boxs which are optional.Have a peice of code run through all the text
        >boxs check if they have a value then take there control name and place
        >it in the SQL sting, I have got this part to work fine the next part is
        >where i'm lost. I tried the code u gave me which puts the SQL in the
        >Query(which is good) but when it runs it turns the first row of the
        >query in to expr1 which in turn dosn't link with my subform..
        >
        >Thanks
        >Nathan[/color]

        Comment

        Working...