Solved

Need RecordSource Guide to loop through records without me.recordsource

Posted on 2009-07-14
5
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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.

739 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