Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Access
3rdpartyusrgrp
access
activexcontrol
adp.sqlserver
commandbarsui
conversion
dataaccess.pages
developers.toolkitode
devtoolkits
externaldata
forms
formscoding
gettingstarted
internet
interopoledde
macros
modulescoding
modulesdaovba
modulesdaovba.ado
multiuser
odbcclientsvr
queries
replication
reports
security
setupconfig
tablesdbdesign
  
 
date: Wed, 2 Jul 2008 19:15:31 -0700 (PDT),    group: microsoft.public.access.modulescoding        back       


looping parsing problem   
Can someone tell me best way of correcting the following code, in
which I would like to move through the rows of a six-row dynaset,
and on each line of the dynaset look for particular field values.
If such a value is found, then the entire process can be exited.
I've written the following, but it's not progressing thru the dynaset
rows.

Set MyDB = CurrentDb()
    Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
  For l = 0 To MyDB.Recordsets.Count - 1

        Set TempRecordset = MyDB.Recordsets(l)



        For k = 11 To 14        'Fields of interest in each row


     v = TempRecordset.Fields(k).Value
              If v = "22" Then			'satisfactory result for exiting
process


            End If

            Next k

    Next l
TempRecordset.close

Thanks
Richard
date: Wed, 2 Jul 2008 19:15:31 -0700 (PDT)   author:   unknown

Re: looping parsing problem   
On Wed, 2 Jul 2008 19:15:31 -0700 (PDT), richaluft@cs.com wrote:

if v="22" then Goto DoneWithLoop

(below your outermost For loop:
DoneWithLoop:

-Tom.


>Can someone tell me best way of correcting the following code, in
>which I would like to move through the rows of a six-row dynaset,
>and on each line of the dynaset look for particular field values.
>If such a value is found, then the entire process can be exited.
>I've written the following, but it's not progressing thru the dynaset
>rows.
>
>Set MyDB = CurrentDb()
>    Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
>  For l = 0 To MyDB.Recordsets.Count - 1
>
>        Set TempRecordset = MyDB.Recordsets(l)
>
>
>
>        For k = 11 To 14        'Fields of interest in each row
>
>
>     v = TempRecordset.Fields(k).Value
>              If v = "22" Then			'satisfactory result for exiting
>process
>
>
>            End If
>
>            Next k
>
>    Next l
>TempRecordset.close
>
>Thanks
>Richard
date: Wed, 02 Jul 2008 21:28:43 -0700   author:   Tom van Stiphout

Re: looping parsing problem   
On Jul 2, 10:15 pm, richal...@cs.com wrote:
> Can someone tell me best way of correcting the following code, in
> which I would like to move through the rows of a six-row dynaset,
> and on each line of the dynaset look for particular field values.
> If such a value is found, then the entire process can be exited.
> I've written the following, but it's not progressing thru the dynaset
> rows.
>
> Set MyDB = CurrentDb()
>     Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
>   For l = 0 To MyDB.Recordsets.Count - 1
>
>         Set TempRecordset = MyDB.Recordsets(l)
>
>         For k = 11 To 14        'Fields of interest in each row
>
>      v = TempRecordset.Fields(k).Value
>               If v = "22" Then                        'satisfactory result for exiting
> process
>
>             End If
>
>             Next k
>
>     Next l
> TempRecordset.close
>
> Thanks
> Richard

Tom;
No, its not that I'm not exiting the loop if I find "22" in the first
row of dynaset. I already have a GOTO line in the code (that I didn't
bother including in my text).
The problem is that this code, as written, is not progressing thru the
dynaset to look for value = 22 in fields in the second, third, etc.
rows of the dynaset if the value is not found in first row.
I'm not sure where the error is, but "l" never goes past "0"----------
ie.--Recordsets.Count =1 (instead of TopN, which is really Top6.
date: Thu, 3 Jul 2008 05:32:27 -0700 (PDT)   author:   unknown

Re: looping parsing problem   
Hi Richard,

I think your problem lies with your "treatment" of the recordset.  You can't 
treat it as an array, and refer to records within it via a Recordset(n) 
construct.  You have to step through the recordset using the .MoveNext 
method.

Something like the following (late-night air-code):

    Dim MyDB as DAO.Database
    Dim MyData as DAO.Recordset

    Set MyDB = CurrentDb()
    Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
    Do Until MyData.EOF
        For k = 11 To 14 'Fields of interest in each row
            v = MyData.Fields(k).Value
            If v = "22" Then 'satisfactory result for exiting
                'process
            End If
        Next k
        MyData.MoveNext
    Loop
    MyData.close
    Set MyData = Nothing

Your process code should also close the recordset and set it to Nothing if 
it is exiting the routine via an ExitSub statement (although it probably 
won't crash if you don't; but it's good practice to not leave things open if 
they should be closed).

HTH,

Rob


 wrote in message 
news:348ce667-814b-4d6a-9f4c-5c2b3bf289cb@d1g2000hsg.googlegroups.com...
On Jul 2, 10:15 pm, richal...@cs.com wrote:
> Can someone tell me best way of correcting the following code, in
> which I would like to move through the rows of a six-row dynaset,
> and on each line of the dynaset look for particular field values.
> If such a value is found, then the entire process can be exited.
> I've written the following, but it's not progressing thru the dynaset
> rows.
>
> Set MyDB = CurrentDb()
> Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
> For l = 0 To MyDB.Recordsets.Count - 1
>
> Set TempRecordset = MyDB.Recordsets(l)
>
> For k = 11 To 14 'Fields of interest in each row
>
> v = TempRecordset.Fields(k).Value
> If v = "22" Then 'satisfactory result for exiting
> process
>
> End If
>
> Next k
>
> Next l
> TempRecordset.close
>
> Thanks
> Richard

Tom;
No, its not that I'm not exiting the loop if I find "22" in the first
row of dynaset. I already have a GOTO line in the code (that I didn't
bother including in my text).
The problem is that this code, as written, is not progressing thru the
dynaset to look for value = 22 in fields in the second, third, etc.
rows of the dynaset if the value is not found in first row.
I'm not sure where the error is, but "l" never goes past "0"----------
ie.--Recordsets.Count =1 (instead of TopN, which is really Top6.
date: Thu, 3 Jul 2008 23:29:26 +1000   author:   Rob Parker VETHIS

Re: looping parsing problem   
On Thu, 3 Jul 2008 05:32:27 -0700 (PDT), richaluft@cs.com wrote:

Ah, I didn't even see that in first instance. You're missing
TempRecordset.MoveNext above the "Next I" line.

Also curious is why you're going over all recordsets in MyDB. Much
more typical is to go over MyData, it being the only recordset you
want to work with.

-Tom.



>On Jul 2, 10:15 pm, richal...@cs.com wrote:
>> Can someone tell me best way of correcting the following code, in
>> which I would like to move through the rows of a six-row dynaset,
>> and on each line of the dynaset look for particular field values.
>> If such a value is found, then the entire process can be exited.
>> I've written the following, but it's not progressing thru the dynaset
>> rows.
>>
>> Set MyDB = CurrentDb()
>>     Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
>>   For l = 0 To MyDB.Recordsets.Count - 1
>>
>>         Set TempRecordset = MyDB.Recordsets(l)
>>
>>         For k = 11 To 14        'Fields of interest in each row
>>
>>      v = TempRecordset.Fields(k).Value
>>               If v = "22" Then                        'satisfactory result for exiting
>> process
>>
>>             End If
>>
>>             Next k
>>
>>     Next l
>> TempRecordset.close
>>
>> Thanks
>> Richard
>
>Tom;
>No, its not that I'm not exiting the loop if I find "22" in the first
>row of dynaset. I already have a GOTO line in the code (that I didn't
>bother including in my text).
>The problem is that this code, as written, is not progressing thru the
>dynaset to look for value = 22 in fields in the second, third, etc.
>rows of the dynaset if the value is not found in first row.
>I'm not sure where the error is, but "l" never goes past "0"----------
>ie.--Recordsets.Count =1 (instead of TopN, which is really Top6.
date: Thu, 03 Jul 2008 06:42:45 -0700   author:   Tom van Stiphout

Re: looping parsing problem   
On Jul 3, 9:29 am, "Rob Parker"
<NOSPAMrobppar...@optusnet.com.au.REMOVETHIS> wrote:
> Hi Richard,
>
> I think your problem lies with your "treatment" of the recordset.  You can't
> treat it as an array, and refer to records within it via a Recordset(n)
> construct.  You have to step through the recordset using the .MoveNext
> method.
>
> Something like the following (late-night air-code):
>
>     Dim MyDB as DAO.Database
>     Dim MyData as DAO.Recordset
>
>     Set MyDB = CurrentDb()
>     Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
>     Do Until MyData.EOF
>         For k = 11 To 14 'Fields of interest in each row
>             v = MyData.Fields(k).Value
>             If v = "22" Then 'satisfactory result for exiting
>                 'process
>             End If
>         Next k
>         MyData.MoveNext
>     Loop
>     MyData.close
>     Set MyData = Nothing
>
> Your process code should also close the recordset and set it to Nothing if
> it is exiting the routine via an ExitSub statement (although it probably
> won't crash if you don't; but it's good practice to not leave things open if
> they should be closed).
>
> HTH,
>
> Rob
>
>  wrote in message
>
> news:348ce667-814b-4d6a-9f4c-5c2b3bf289cb@d1g2000hsg.googlegroups.com...
> On Jul 2, 10:15 pm, richal...@cs.com wrote:
>
>
>
>
>
> > Can someone tell me best way of correcting the following code, in
> > which I would like to move through the rows of a six-row dynaset,
> > and on each line of the dynaset look for particular field values.
> > If such a value is found, then the entire process can be exited.
> > I've written the following, but it's not progressing thru the dynaset
> > rows.
>
> > Set MyDB = CurrentDb()
> > Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
> > For l = 0 To MyDB.Recordsets.Count - 1
>
> > Set TempRecordset = MyDB.Recordsets(l)
>
> > For k = 11 To 14 'Fields of interest in each row
>
> > v = TempRecordset.Fields(k).Value
> > If v = "22" Then 'satisfactory result for exiting
> > process
>
> > End If
>
> > Next k
>
> > Next l
> > TempRecordset.close
>
> > Thanks
> > Richard
>
> Tom;
> No, its not that I'm not exiting the loop if I find "22" in the first
> row of dynaset. I already have a GOTO line in the code (that I didn't
> bother including in my text).
> The problem is that this code, as written, is not progressing thru the
> dynaset to look for value = 22 in fields in the second, third, etc.
> rows of the dynaset if the value is not found in first row.
> I'm not sure where the error is, but "l" never goes past "0"----------
> ie.--Recordsets.Count =1 (instead of TopN, which is really Top6.- Hide quoted text -
>
> - Show quoted text -
Tom
Yes, this effects the correct action.  Actually, I left out closing
data in my online code text
Thanks again
R
date: Thu, 3 Jul 2008 09:12:43 -0700 (PDT)   author:   unknown

Re: looping parsing problem   
On Jul 3, 8:32 am, richal...@cs.com wrote:
> On Jul 2, 10:15 pm, richal...@cs.com wrote:
>
>
>
>
>
> > Can someone tell me best way of correcting the following code, in
> > which I would like to move through the rows of a six-row dynaset,
> > and on each line of the dynaset look for particular field values.
> > If such a value is found, then the entire process can be exited.
> > I've written the following, but it's not progressing thru the dynaset
> > rows.
>
> > Set MyDB = CurrentDb()
> >     Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
> >   For l = 0 To MyDB.Recordsets.Count - 1
>
> >         Set TempRecordset = MyDB.Recordsets(l)
>
> >         For k = 11 To 14        'Fields of interest in each row
>
> >      v = TempRecordset.Fields(k).Value
> >               If v = "22" Then                        'satisfactory result for exiting
> > process
>
> >             End If
>
> >             Next k
>
> >     Next l
> > TempRecordset.close
>
> > Thanks
> > Richard
>
> Tom;
> No, its not that I'm not exiting the loop if I find "22" in the first
> row of dynaset. I already have a GOTO line in the code (that I didn't
> bother including in my text).
> The problem is that this code, as written, is not progressing thru the
> dynaset to look for value = 22 in fields in the second, third, etc.
> rows of the dynaset if the value is not found in first row.
> I'm not sure where the error is, but "l" never goes past "0"----------
> ie.--Recordsets.Count =1 (instead of TopN, which is really Top6.- Hide quoted text -
>
> - Show quoted text -

No, this doesn't help, but rob parker's solution sees the light.
Thanks,
R
date: Thu, 3 Jul 2008 09:14:20 -0700 (PDT)   author:   unknown

Re: looping parsing problem   
>>Set MyDB = CurrentDb()

I see this a lot.  Why even make an database object when you can just
use CurrentDb directly?  Dim the Recordset, then instantiate as such:
Set rsCopy = CurrentDb.OpenRecordset("filecopy")

CurrentDb has all the properties, collections, and methods you're
using anyway.  I just thought not making the Database object would
save clock cycles and memory.
date: Thu, 3 Jul 2008 09:54:24 -0700 (PDT)   author:   krazymike

Re: looping parsing problem   
You've described a "how".

If I squint and hold my tongue just so, what you've described might be 
something you could handle with a query (set-oriented) instead of by looping 
through a recordset.

If you'll provide a bit more specifics on the "what" and "why", folks here 
may be able to offer alternate approaches.

Regards

Jeff Boyce
Microsoft Office/Access MVP

 wrote in message 
news:ac94c9ce-a26b-4580-80d6-c10adc43b865@d1g2000hsg.googlegroups.com...
> Can someone tell me best way of correcting the following code, in
> which I would like to move through the rows of a six-row dynaset,
> and on each line of the dynaset look for particular field values.
> If such a value is found, then the entire process can be exited.
> I've written the following, but it's not progressing thru the dynaset
> rows.
>
> Set MyDB = CurrentDb()
>    Set MyData = MyDB.OpenRecordset("TopN", dbOpenDynaset)
>  For l = 0 To MyDB.Recordsets.Count - 1
>
>        Set TempRecordset = MyDB.Recordsets(l)
>
>
>
>        For k = 11 To 14        'Fields of interest in each row
>
>
>     v = TempRecordset.Fields(k).Value
>              If v = "22" Then 'satisfactory result for exiting
> process
>
>
>            End If
>
>            Next k
>
>    Next l
> TempRecordset.close
>
> Thanks
> Richard
date: Mon, 7 Jul 2008 10:18:41 -0700   author:   Jeff Boyce

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us