Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 6th, 2006, 06:06 AM
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default I can only get 1 field in recordsets?

I have have a problem in VB within my database. I am trying to move through recordsets and print the value of different fields (at this point, just to a message box). I can only get the values of 1 field only . Usually the index or first field of any recodrset. I was using Access 2000 and recently loaded 2003 in an attempt to overcome the problem.

Here is the code


Private Sub Command71_Click()

Dim dbs As DAO.Database
Dim rsTable As DAO.Recordset
Dim booNext As Boolean
Dim intcount As Integer
Dim intLast As Integer


Set dbs = CurrentDb

'Open the table-type recordset
Set rsTable = dbs.OpenRecordset("Table1")

'First message
MsgBox "please wait while the processing is completed"

'Get the number of records
With rsTable
    .MoveFirst
    .MoveLast
    intLast = .RecordCount
    .MoveFirst
End With

'Cylce through the recordset
    For intLast = 0 To (intLast - 1)
        With rsTable
        Debug.Print , !field1, !field2
        MsgBox "the field values are for field 1 " & !field1 & " for field 2 " & !filed5
        .MoveNext
        End With
    Next


End Sub



Any ideas would be appreciated

Gary.

 
Old February 6th, 2006, 09:18 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can send the values to the messagebox like this:

'Cycle through the recordset
rs.MoveFirst
Do Until rs.EOF
   MsgBox "Field Value 1: " & rs.Fields(0) & vbCrLf & _
          "Field Value 2: " & rs.Fields(1) & vbCrLf & _
          ...
   rs.MoveNext
Loop


HTH


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordsets JezLisle Access VBA 11 July 17th, 2007 03:47 AM
Help with Recordsets voskoue Access VBA 1 January 23rd, 2007 08:36 AM
Assigning Recordsets mrjeret BOOK: Access 2003 VBA Programmer's Reference 0 July 6th, 2006 09:39 AM
Need help with recordsets chacquard Access VBA 5 June 21st, 2004 11:58 PM
Recordsets bph Access VBA 17 February 17th, 2004 03:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.