Solved

Query two at a time in a recordset

Posted on 2006-11-14
3
148 Views
Last Modified: 2010-04-30
I am trying to retrieve records in my Access database.  I use the following code to retrieve records and place them in text fields.  However, I only allow two text boxes on my form and the results from my query are definitely more than two.  So I need to be able to collect two records at a time in a record set until I finish modifying the data in the that record set.  

How do I write the code to input the two values at a time from the queried recordset into Text1 and Text2?

esql = "select * from frm2SectionI where ID =" & Text1
        rec.Open (esql), conn, adOpenDynamic, adLockOptimistic
       
 

        Text1 = rec.Fields(1)
        Text2 = rec.Fields(2)


       
        If Not rec.EOF Then rec.MoveNext
        rec.Close
0
Comment
Question by:al4629740
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17943457
why can't you do

esql = "select * from frm2SectionI where ID =" & Text1
        rec.Open (esql), conn, adOpenDynamic, adLockOptimistic
if not rec.EOF = roc.BOF and rec.EOF = false then
        Text1 = rec.Fields(1)
        rec.MoveNext
end if
if not rec.EOF = roc.BOF and rec.EOF = false then
        Text2 = rec.Fields(1)
end if
rec.Close

look at the first record - then look at the second, put the first in the first box, the second in the second box
0
 

Author Comment

by:al4629740
ID: 17943513
What if I want to go backwards in the same record set.  Maybe I am on record 7 and 8, but i want to go back to record 5 and 6?
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17943531
why can't you use

rec.moveprevious

to move backwards?
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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