Solved

Need RecordSource Guide to loop through records without me.recordsource

Posted on 2009-07-14
5
290 Views
Last Modified: 2013-11-27
I need a general how-to on creating and using a new recordsource... one other than the me.recordsource... to loop through records in a table.

I need to run through this recordsource in a public function that will be used within the looping through a me.recordsource.
0
Comment
Question by:travisjbennett
  • 3
  • 2
5 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 24853254
You did not explain what you ultimate goal is here, so I will present a generic example.
On your form put a button to run code like this:

'
Dim rst as DAO.Recordset
Set rst=CurrentDB.Openrecordset("YourTableName")

    rst.movefirst
   
    Do Until rst.eof
        'Do Something
        rst.movenext
    Loop
   
msgbox "Done"

rst.Close
Set rst=Nothing
'

JeffCoachman
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24853564
So how do I refer to a field in that recordset?
When I try to use [ID] it says Run-time error '2465': (Databasename) can't find the field 'ID' reffered to in your expression.
When I try to use YourTableName.[ID] it says Run-time error '424': Object required.
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 500 total points
ID: 24853901
rst!ID
0
 
LVL 1

Author Comment

by:travisjbennett
ID: 24854174
Beautiful. Works with the bang, but not the dot.
Thanks boaq!
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24855318
;-)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question