Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 6th, 2006, 06:06 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
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.

Reply With Quote
  #2 (permalink)  
Old February 6th, 2006, 09:18 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:34 PM.


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