Improving code

M

Maracay

Hi guys, there is a better way to do this routine, I need to read a table
(.rsa) and compare the right and left of all the fields of this table with
another table (.rsj)
Example:
The word “Manager†I need to look for this word at the end and beginning of
each field of each record.

Sales Manager
Manager
Manager of Department

My question is the Do until cycle is the only option to do this kind of
search, 1 record at a time or there is a better way?.

Thank

Se the code, (the code is longer, has another searches, hopefully I didn’t
miss anything)



If rsa.RecordCount > 0 Then
Do Until rsa.EOF
For Each fld In rsa.Fields
rsj.MoveFirst
Do Until rsj.EOF
If rsj!Title = Left(fld.Value, Len(rsj!Title)) Or rsj!Title
= Right(fld.Value, Len(rsj!Title)) Then
rsc.AddNew
rsc!StatisticTitle = fld.Name
rsc!nCountTitle = 1
rsc.Update
Exit Do
End If
rsj.MoveNext
Loop
Next
rsa.MoveNext
Loop
End If
MsgBox "Done"
 
K

Klatuu

What you have isn't bad, but you could do it with queries. It would probably
run a little faster.

You could write an append query that will append the records you need and it
can be filtered using the same logic you are using in your VBA code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top