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 August 30th, 2003, 10:06 AM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Record Pointer moves, do not get current fields

Whats wrong with this:

Thanx for any suggestions.

Option Compare Database
Option Explicit
Dim CurDb As DAO.Database
Dim MEMPass As DAO.Recordset
Dim memTEST As String

Private Sub Command0_Click()
Set CurDb = CurrentDb()
Set MEMPass = CurDb.OpenRecordset("sysPasswordsT")
DoCmd.OpenTable "sysPasswordsT"
DoCmd.GoToRecord acDataTable, "sysPassWordsT", acFirst
DoCmd.GoToRecord acDataTable, "sysPassWordsT", acNext
DoCmd.GoToRecord , "sysPassWordsT", acNext
memTEST = MEMPass!Password
MsgBox (memTEST) 'this box returns first record, not 3 record !?
End Sub

MsgBox should return data from password in third record, yes?

help! Thanx.

 
Old August 30th, 2003, 11:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi James,

Your code is navigating through the physical base table, not the recordset object you created. Use the recordset objects Move methods to navigate the recordset:

Dim CurDb As DAO.Database
Dim MEMPass As DAO.Recordset
Dim memTEST As String

Private Sub Command0_Click()
    Set CurDb = CurrentDb()
    Set MEMPass = CurDb.OpenRecordset("sysPasswordsT")
    MEMPass.MoveFirst
    MEMPass.MoveNext
    MEMPass.MoveNext
    memTEST = MEMPass!Password
    MsgBox (memTEST) ' displays third record
End Sub

HTH,

Bob


 
Old August 30th, 2003, 12:15 PM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:)thanx Bob.






Similar Threads
Thread Thread Starter Forum Replies Last Post
mouse wheel moves to new record on subform lhedquist Access 7 January 19th, 2006 11:42 AM
Current Record Number Base VB How-To 1 December 7th, 2005 05:26 PM
UPDATE CURRENT RECORD ranakdinesh Classic ASP Databases 6 March 18th, 2005 02:22 AM
Error 3021 - No Current Record JackNimble BOOK: Expert One-on-One Access Application Development 5 October 2nd, 2004 03:26 PM
Print current record vladimir Access 2 September 10th, 2003 11:53 PM





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