Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to "reset" a view for successive .browse

Status
Not open for further replies.

sblocher

IS-IT--Management
Jun 17, 2003
28
US
I am looping thru an array of data, where one element of the array contains a customer ID. As i loop thru each element, i want to retrieve the customer record based on IDCUST, so i set the browse condition accordingly. However, my view is open in IDCUST order, but the customer ID values in my array are in no particular order. The .Browse works the first time into the loop, and will continue to work as long as the next customer ID follows the previous customer. But .browse fails if the customer ID comes before.

I inserted three statements to force a new view with all the records and to position myself at the top of that view. Then everything works. This seems like a kluge.

I must be doing something wrong. There must be a better way! I can't seem to find a method that does what i want, nor can i find an example that applies to this.


Code:
...
Dim BatchCUST As AccpacCOMAPI.AccpacView
Dim BatchCUSTFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AR0024", BatchCUST
Set BatchCUSTFields = BatchCUST.Fields

...

For nLoopCounter = 1 To nInvCounter Step 1
    'Next three statements needed to "reset" the old view so new browse works? 
    BatchCUST.Browse "", True
    BatchCUST.Fetch
    BatchCUST.GoTop

    sGetCustStr = "(IDCUST = """ & sInvArray(nLoopCounter, 2) & """)"

    BatchCUST.Browse sGetCustStr, True
 
If you know the customer number exists then a faster way would be to do a .read. Something like this (untested code warning):

Code:
BatchCUST.fields('IDCUST').PutWithoutVerification (sInvArray(nLoopCounter, 2))
BatchCUST.read

.read returns true if the record is found so you might want to do some error checking just in case.

Djangman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top