Solved

Query two at a time in a recordset

Posted on 2006-11-14
3
147 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now