Results 1 to 5 of 5

Thread: Page for View All Results. HELP

  1. #1
    Join Date
    Jun 2006
    Posts
    30

    Text Field showing ALL Results from SQL Query

    EDITED:
    Hi there,

    I'm basically trying to create a '2nd' page on the same form that will perform SQL query and return ALL the records and fields specified in the SQL onto the Text box on the form.

    QS: Do i need to use recordset to do this?

    QS: How do I return ALL The rows and fields specified?

    QS: How do I "refresh" each time I come-back to this page on the form?

    Thanks.

    ===================================
    I have built a form with 2 pages, 1 for inputting the data, the other page for showing what has been saved into the table.

    can i simply have a textbox in the "View Test Result" that shows all the records in a particular table say tbl_test?

    do i need to use record set?

    ' gets the test results
    sqlViewRslt = "select test_no, test_date, test_rslt, issue_no" & _
    " , tester_name, comment, file_loc" & _
    " from tbl_test_rslt" & _
    " order by 2,1 asc;"

    how do i execute this so that it returns everything onto the text field??

    also how do i refresh whenever i go into this page?

    thanks
    Last edited by rexwrx; 06-14-2006 at 06:26 PM. Reason: clearer explaination

  2. #2
    Join Date
    Dec 2005
    Posts
    18
    Using recordset you can put its data to any control in your way:

    Code:
    Dim rs as Recordset
    Set rs = CurrenDb.OpenRecordset("SELECT * FROM your_table")
    
    while Not rs.EOF
       YourTextBox = YourTextBox & rs.Fields("your_field")
       rs.MoveNext
    wend

  3. #3
    Join Date
    Jun 2006
    Posts
    30
    thanks for that!

    seems that i need to concatenate each and every field in the table and formating becomes an issue.

    Private Sub Text0_Enter()
    Dim rs As DAO.Recordset
    Dim db As DAO.Database
    Dim sqltxt As String

    Set db = CurrentDb

    sqltxt = "select * from tbl_test_rslt"

    Set rs = db.OpenRecordset(sqltxt)

    Me.Text0 = ""

    While Not rs.EOF
    Me.Text0 = Me.Text0 & rs.Fields("test_no") & " " & rs.Fields("issue_no") & " " & _
    rs.Fields("test_date") & " " & rs.Fields("test_rslt") & _
    " " & rs.Fields("tester_name")

    rs.MoveNext
    Wend
    End Sub

    tried it on a sample form, the result on the text field is not formatted correctly.

    i'd assume the best alternative would be to use sub-form/report and generate the result from access's own query??

  4. #4
    Join Date
    Dec 2005
    Posts
    18
    Quote Originally Posted by rexwrx
    ...
    i'd assume the best alternative would be to use sub-form/report and generate the result from access's own query??
    Definitly yes. Using subform (TableView kind) is the best solution in such case

  5. #5
    Join Date
    Jun 2006
    Posts
    30
    thanks champ!

Posting Permissions

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