Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    Unanswered: rs.fields assigned to text box

    I have the following code that returns the data that I want. This data I then want to display in a
    form.



    Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
    "", rs.Fields(2).Name, rs.Fields(3).Name

    While Not rs.EOF
    Debug.Print rs.Fields(0), rs.Fields(1), _
    rs.Fields(2), rs.Fields(3)
    rs.MoveNext


    How do I assign the rs.Fields(0), rs.Fields(1), _
    rs.Fields(2), rs.Fields(3) to text boxes in my form?

  2. #2
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    You can't store more than one value in a textbox. If you're rolling through a recordset, you'll just end up with the last record's values in the textboxes. Maybe try using a listbox with the .AddItem method in your loop.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Me.TextBox1.Value = rs.Fields(2).Value
    EDIT: What he said ^^
    George
    Home | Blog

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ummm: you can stuff many fields in one textbox.

    DAO-HOW (assuming rs is a DAO.recordset)
    dim rfield as DAO.field
    for each rfield in rs.fields
    sometextbox = sometextbox & rfield & "~"
    next

    ....what you can't do (easily) is edit the mess you have thus created and stuff it back into the table.

    probably sADO can do similar - i don't know

    izy
    currently using SS 2008R2

Posting Permissions

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