It's because that snippet of code isn't valid C#. this other StackOverflow answer explains why. To summarize that answer, the C# specification states that the body of an if statement must be an embedded-statement, which does not include statements that are variable declarations.
To get your code to stop causing that error, you can try just throwing brackets around the if statement body:
if (dtpFrom.DateTime != null)
{
Func<BAL.Receipt , DateTime? > expr = receipt => receipt.Date ;
}
Although this won't do much of anything, since you're just storing that lambda in a temporary variable of type Func<,> which only has scope in the if statement. You'll either have to use it within the if state body or store it somewhere else.