From your script, $Cue is the value passed as a script parameter? and you have this step: Set variable [$Cue ; value: Get ( ScriptParameter ) ] preceding the steps shown above?
You'd also need a Show All Records at the start here since you are comparing $I to Get ( TotalRecordCount ). (Instead, you can use the exit after last option in the go to record step.)
Use this expression as your If step:
If [ ( $Cue > Spots::CueIn ) and ( $Cue < Spots::CueOut ) ]
Your show custom dialog might be misleading here as it comes just before you change the value of the variables. I'd put it after the set variable expression.
That said, I don't see any obvious errors. are cuein and cueout fields of type number?
Try simplifying the e
You can also do this without the looping script if you perform a find:
Enter Find Mode 
Set field [Spots::cueIn ; "<" & $Cue ]
Set field [Spots::cueOut ; ">" & $Cue]
Set error Capture [on]