This code works:
gErrorHandler.Push("frmItemcodes.cmdRunMethodOne_Click")
If gfHANDEL_ERRORS Then On Error GoTo PROC_ERR
Dim query = KQdbs.Items.Where(Function(f) f.Itemcode > 8000)
Me.dgvItemcodes.DataSource = query.ToList
PROC_EXIT:
gErrorHandler.Pop()
Exit Sub
PROC_ERR:
gErrorHandler.HandleError()
Resume PROC_EXIT
but if I change the literal 8000 to any kind of variable I get the following error:
Error BC36597 'On Error GoTo PROC_ERR' is not valid because 'PROC_ERR' is inside a scope that defines a variable that is used in a lambda or query expression.
I have no idea why
If I change the code in the body to this:
Dim query = From item In KQdbs.Items Where item.Itemcode = 8000
Me.dgvItemcodes.DataSource = query.ToList
The results are the same, the literal works a variable returns the same error as above