Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts
    I have the following snippet of code to find the first occurrence of an IsMaster flag and then do something with it.

    Code:
    With rst
        .MoveFirst                     'Find the first matching record (assuming it's a string value)
        .FindFirst "[IsMaster] = True"
        If Not .NoMatch Then           'If NoMatch is true, there is no matching record so Not NoMatch means you found one
        MasterJob = ![Master]
        GoSub CalcMaster
        End If
    End With
    Can someone please properly set up a Do...Loop to then go on and find any more IsMaster flags and then finish gracefully. My first effort got me in a continuous loop.
    "Heading for the deep end"

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try

    Code:
    With rst
     .MoveFirst
     .FindFirst "[IsMaster] = True"
     Do While Not .NoMatch
      ' Do stuff here
      .FindNext "[IsMaster] = True"
     Loop
     .Close
    End With
    An alternative would be to open a recordset that selects only the records with IsMaster = True. You can then loop through all records:

    Code:
    With rst
     .MoveFirst
     Do While Not .EOF
      ' Do stuff here
      .MoveNext
     Loop
     .Close
    End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •