Hi,

I've written two versions of the same code, the purpose of which is to associate records from one table to the appropriate sales rep based upon the record's postal code. Version 2 is 3x slower than version 1, and I have isolated the performance difference between the two versions to the following lines (i.e. all other code is the same in both versions):

Version 1:

*FindCSR is the function name that returns the name of a sales rep if a match is made
*blnCheck is a Boolean variable
*postalcode is a parameter passed to this procedure containing the record's postal code value
*ZipRange is a postal code range (i.e. 925*) taken from the sales rep table

blnCheck = postalcode Like ZipRange
If blnCheck = True Then
FindCSR = rstCSR.Fields(FLD_CSR_ID)
GoTo FindCSR_Exit
End If

Version 2:

*FindCSR is the function name that returns the name of a sales rep if a match is made
*postalcode is a parameter passed to this procedure containing the record's postal code value
*postalcode_low is a value grabbed from the sales rep table that corresponds to the low end of a postal code range (i.e. 92500)
*postalcode_high is a value grabbed from the sales rep table that corresponds to the high end of a postal code range (i.e. 92599)

If postalcode >= postalcode_low _
And postalcode <= postalcode_high Then
FindCSR = rstCSR.Fields(FLD_CSR_ID)
GoTo FindCSR_Exit
End If

Why would Version 2 take 3 times as long as Version 1? Is there anything I can do to improve the performance?

Any advice is appreciated. If I need to provide more info, let me know.

Thanks,

-Mike