ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Correct VBA for DO WHILE i.e. X=X AND NOT RS.EOF (https://www.excelbanter.com/excel-programming/425467-correct-vba-do-while-i-e-x%3Dx-not-rs-eof.html)

[email protected]

Correct VBA for DO WHILE i.e. X=X AND NOT RS.EOF
 
2003/2007

Attempting to:

CASE #1

Do While TranNumMem = TransactionsRS!TranNum AND NOT RS.EOF

' xxxxxxx
' xxxxxxx
rs.movenext
Loop

The clause TranNumMem = TransactionsRS!TranNum works but the
AND NOT RS.EOF is not working

I worked around with:

CASE #2

Do While TranNumMem = TransactionsRS!TranNum

' xxxxxxx
' xxxxxxx
rs.movenext
If RS.EOF Then Exit Do

Loop


How could I make CASE #1 work??

TIA EagleOne

Code Johnny[_2_]

Correct VBA for DO WHILE i.e. X=X AND NOT RS.EOF
 
Nothing wrong with how you're doing it, however you may wish to try using
the Recordset as the main section of the loop, and the test inside that loop.
Something like the following.
'New Version of Case #1
Do While Not RS.EOF
'01 - Test for TranNumMem
If TranNumMem = TransactionsRS!TranNum Then Exit Do
' xxxxxxx
' xxxxxxx

RS.movenext
Loop 'While Not RS.EOF




" wrote:

2003/2007

Attempting to:

CASE #1

Do While TranNumMem = TransactionsRS!TranNum AND NOT RS.EOF

' xxxxxxx
' xxxxxxx
rs.movenext
Loop

The clause TranNumMem = TransactionsRS!TranNum works but the
AND NOT RS.EOF is not working

I worked around with:

CASE #2

Do While TranNumMem = TransactionsRS!TranNum

' xxxxxxx
' xxxxxxx
rs.movenext
If RS.EOF Then Exit Do

Loop


How could I make CASE #1 work??

TIA EagleOne


[email protected]

Correct VBA for DO WHILE i.e. X=X AND NOT RS.EOF
 
Code Johnny wrote:

Nothing wrong with how you're doing it, however you may wish to try using
the Recordset as the main section of the loop, and the test inside that loop.
Something like the following.
'New Version of Case #1
Do While Not RS.EOF
'01 - Test for TranNumMem
If TranNumMem = TransactionsRS!TranNum Then Exit Do
' xxxxxxx
' xxxxxxx

RS.movenext
Loop 'While Not RS.EOF




" wrote:

2003/2007

Attempting to:

CASE #1

Do While TranNumMem = TransactionsRS!TranNum AND NOT RS.EOF

' xxxxxxx
' xxxxxxx
rs.movenext
Loop

The clause TranNumMem = TransactionsRS!TranNum works but the
AND NOT RS.EOF is not working

I worked around with:

CASE #2

Do While TranNumMem = TransactionsRS!TranNum

' xxxxxxx
' xxxxxxx
rs.movenext
If RS.EOF Then Exit Do

Loop


How could I make CASE #1 work??

TIA EagleOne


[email protected]

Correct VBA for DO WHILE i.e. X=X AND NOT RS.EOF
 
Thanks

Code Johnny wrote:

Nothing wrong with how you're doing it, however you may wish to try using
the Recordset as the main section of the loop, and the test inside that loop.
Something like the following.
'New Version of Case #1
Do While Not RS.EOF
'01 - Test for TranNumMem
If TranNumMem = TransactionsRS!TranNum Then Exit Do
' xxxxxxx
' xxxxxxx

RS.movenext
Loop 'While Not RS.EOF




" wrote:

2003/2007

Attempting to:

CASE #1

Do While TranNumMem = TransactionsRS!TranNum AND NOT RS.EOF

' xxxxxxx
' xxxxxxx
rs.movenext
Loop

The clause TranNumMem = TransactionsRS!TranNum works but the
AND NOT RS.EOF is not working

I worked around with:

CASE #2

Do While TranNumMem = TransactionsRS!TranNum

' xxxxxxx
' xxxxxxx
rs.movenext
If RS.EOF Then Exit Do

Loop


How could I make CASE #1 work??

TIA EagleOne



All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com