Results 1 to 7 of 7

Thread: strSQL

  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    I have an SQL statement which I need to tweak:

    strSQL1 = "SELECT TEXT, NEW_HRS From DET WHERE EST_NO = 87359 AND NEW_HRS >0"

    I have a textbox on a form (VB6 Form) which a user can enter his own number.
    I want to replace 87359 with the contents of the textbox instead.


    strSQL1 = "SELECT TEXT, NEW_HRS From DET WHERE EST_NO = TEXT1.Text AND NEW_HRS >0"

    This doesn't work!
    Can someone help with the syntax?

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='D Willett' post='775150' date='14-May-2009 20:33']Hi

    I have an SQL statement which I need to tweak:

    strSQL1 = "SELECT TEXT, NEW_HRS From DET WHERE EST_NO = 87359 AND NEW_HRS >0"

    I have a textbox on a form (VB6 Form) which a user can enter his own number.
    I want to replace 87359 with the contents of the textbox instead.


    strSQL1 = "SELECT TEXT, NEW_HRS From DET WHERE EST_NO = TEXT1.Text AND NEW_HRS >0"

    This doesn't work!
    Can someone help with the syntax?[/quote]
    In Access it's:
    strSQL1 = "SELECT TEXT, NEW_HRS From DET WHERE EST_NO = " & TEXT1.Text & " AND NEW_HRS >0"

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Patt

    Works perfect.

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts
    Actually, you might want to get out of the habit of using .Text (as in TEXT1.Text). In Access (as opposed to VB), the Text property of a control is only addressable if that control has the focus; otherwise you need to use the .Value property (which is the default property).
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    But Dave wrote he's using VB6.

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts
    [quote name='HansV' post='775179' date='14-May-2009 10:01']But Dave wrote he's using VB6.[/quote]
    I missed that, but then again I didn't even expect it given this is an Access forum. And Pat's reply said "In Acces it's", and used the same .Text property.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry to confuse you all on this.
    I used the Access forum because the project I'm trying to build uses VB forms with ODBC & Access data, it just so happened in this case to be the ODBC datasource.

    The information gained of the .text & .value property is very useful, so many thanks again.

Posting Permissions

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