Rx_
Nothing In Moderation
- Local time
- Today, 09:33
- Joined
- Oct 22, 2009
- Messages
- 2,803
Would this Like Statement be as efficient as using the InStr statement?
A well name can have a H or D that always appears in the last 3 characters of its name (Horizontal or Directional)
There is already a existing recordset -
The function is a Rule that is run on the Well Name and returns the T/F to a 2nd table column. Efficiency is important as this may be run many times.
Does the Like statement run in code efficienctly?
It sure codes nicely returning the T/F based on a string comparison.
Notice, there is an H OR D to locate and report a T/F.
I use to use a nested IF Then with the Instr (in string).
Came aross this. Just wondering if it would be more efficient.
A well name can have a H or D that always appears in the last 3 characters of its name (Horizontal or Directional)
There is already a existing recordset -
The function is a Rule that is run on the Well Name and returns the T/F to a 2nd table column. Efficiency is important as this may be run many times.
Does the Like statement run in code efficienctly?
It sure codes nicely returning the T/F based on a string comparison.
Code:
Public Function RE_R73() As Boolean ' Well Name has H or D in last 3 char Well Type
Dim tableValue As Variant
Dim Result As Variant
10 On Error GoTo err_Trap
'RStblvRE_1Seg
20 RE_R73 = False ' false until proven true
30 RStblvRE_1Seg.MoveFirst ' bring pointer to top
40 tableValue = RStblvRE_1Seg.Fields("well_Name")
50 tableValue = Right(tableValue, 3)
60 Result = tableValue Like "*H*" Or tableValue Like "*D*"
' write result to tblvRe_1SegResult
70 RStblvRE_1SegResult.Edit
80 RStblvRE_1SegResult.Fields("RE_R73") = Result
90 RStblvRE_1SegResult.Update
100 Exit Function
err_Trap:
110 Debug.Print "RE_R73 " & Err.Description
End Function
Notice, there is an H OR D to locate and report a T/F.
I use to use a nested IF Then with the Instr (in string).
Came aross this. Just wondering if it would be more efficient.