?
Solved

How to consist this loop?

Posted on 2002-05-17
6
Medium Priority
?
230 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 150 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Independent Software Vendors: 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!

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…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

765 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