View Single Post
 
Old 08-22-2022, 03:50 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Field.Code is a string and refers to the field code not the field result. I think perhaps you are wanting the field result (the text that shows on the page) which is Field.Range.Text

Eg a field like this {Seq Table} would have a Field.Code = "Seq Table" but a Field.Range.Text = "1"

You probably don't need to run a find on a tiny string like this. Perhaps a Like comparison is more efficient.

Working through a loop from the front while deleting some of them is problematic. If you delete an item, all the remaining items move forward one position so the loop then skips an item. You solve this by working backwards through the fields.
Code:
Dim i as integer
For i = analystreport.Fields.Count to 1 Step -1
  If analystreport.Fields(i).Range.Text Like "*[0-9].[0-9]*" then
    tenum = analystreport.Fields(i).Range.Text
  Else
    analystreport.Fields(i).Delete
  End If
Next i
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote