• strSQL

    Author
    Topic
    #459831

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #1160514

      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?

      In Access it’s:
      strSQL1 = “SELECT TEXT, NEW_HRS From DET WHERE EST_NO = ” & TEXT1.Text & ” AND NEW_HRS >0″

      • #1160517

        Thanks Patt

        Works perfect.

        • #1160525

          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).

          • #1160531

            But Dave wrote he’s using VB6.

            • #1160533

              But Dave wrote he’s using VB6.

              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.

            • #1160554

              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.

    Viewing 0 reply threads
    Reply To: strSQL

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: