Results 1 to 6 of 6

Thread: Adodc1 (vb6)

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

    Adodc1 (vb6)

    Hello all.

    I'm new to using the adodc ADO control and need a little help here.
    I have a form "frmDB" with an Adodc1 control set to a DSN(= MM) and to a table "PRT"
    The form also has an unbound listbox "List1".

    I want to fill the listbox with data linked to a textbox on "frm1280"

    I need some help with an SQL statement to fill the list.

    <pre>Dim strSQL As String
    strSQL = "SELECT PRT.EST_NO, PRT.SUP_NO, PRT.ITM_DES, PRT.QTY, PRT.NET_CST, PRT.RET_CST
    FROM PRT WHERE (((PRT.EST_NO)=frm1280!txtEST);"
    Execute strSQL</pre>




    Once I have filled the list, I should be ok with a number of things I want to do with the data.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adodc1 (vb6)

    I don't have VB6 available at the moment, but I think you have to set theDataSource property of the list box to the name of the ADO data control, and set the RecordSource of the ADO data control to the appropriate SQL string
    <code>
    Dim strSQL As String
    strSQL = "SELECT EST_NO, SUP_NO, ITM_DES, QTY, NET_CST, RET_CST " & _
    "FROM PRT WHERE EST_NO = " & frm1280.txtEST
    Me.Adodc1.RecordSource = strSQL
    </code>
    Note: if EST_NO is a text field, use

    <code>... EST_NO = '" & frm1280.txtEST & "'"</code>

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

    Re: Adodc1 (vb6)

    Pretty close Hans, but I get this error:

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adodc1 (vb6)

    I'd try starting with a very simple SQL string, for example

    strSQL = "SELECT * FROM PRT"

    If that works, try making the SQL string a bit more complex step by step:
    - Specify individual fields instead of *
    - Add a WHERE clause with a fixed condition
    etc.

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

    Re: Adodc1 (vb6)

    Hans

    I'm getting no-where with this error.

    Are there any alternatives ?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adodc1 (vb6)

    I'm sorry, I can't test the code. Perhaps someone with VB6 will have a suggestion.

Posting Permissions

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