Solved

How to consist this loop?

Posted on 2002-05-17
6
229 Views
Last Modified: 2010-05-02
Hi,

In my project, I have 2 Access 97 tables (T1 & T2), every one contains only 5 records and one field “F1”. Please I need the LOOP Code which makes me fill “F1” in the record (1) of “T1” by the world “RED” THEN fill “F1” in the record (1) of “T2” by the same world  … Then fill “F1” in the record (2) of “T1” by the same world  THEN  fill “F1” in the record (2) of “T2” by the same world  … and so on till the EOF  (I mean going between the 2 tables once here and the other there …..till EOF)
Sirs, I know how to use ADO and how to fill the records. I want your help to show me the LOOP code which makes my request mentioned above.  

ray14
0
Comment
Question by:ray14
[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
6 Comments
 
LVL 1

Accepted Solution

by:
hiranmaya earned 50 total points
ID: 7016706
try this!!!

alltrue = false
RED = true
BLUE = true

Do until
'open T1
.movefirst
If T1EOF is false
if RED =true
'update F1 with Red
RED = false
BLUE = true
elseif BLUE = true
'update F1 with blue
BLUE false
RED =true
end if
.movenext if not eof
else
T1EOF is true    
end if

'open T2
.movefirst
If T2EOF is false
if RED =true
'update F1 with Red
RED = false
BLUE = true
elseif BLUE = true
'update F1 with blue
BLUE false
RED =true
end if
.movenext if not eof
else
T2EOF is true
end if

If T1EOF is true and T2EOF is true then
alltrue = true
endif    
loop alltrue = true


tx in adv.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7016708
'Setup RS1 for T1 and RS2 for T2

RS1.movefirst
RS2.movefirst

do while not RS1.eof
  rs1!F1 = "RED"
  rs1.update
  rs1.movenext
  rs2!F1 = "BLUE"
  rs2.update
  rs2.movenext
loop

'CLOSE THE RECORDSETS

If you know you have 5 records you can use a FOR loop instead

The above assumes T2 has at least as many records as T1
   
mlmcc
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7016711
why do you need to loop?

why not just do,

conn.execute "Update T1 set F1 = 'Red'"
conn.execute "Update T2 set F1 = 'Blue'"

where conn is your adodb.connection?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ray14
ID: 7016739

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7019246
bobbit31

WIll tht update all records?

mlmcc
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7021576
> WIll tht update all records?

it should
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

726 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