Use declarative validation...
Suppose your attachment field is called field1 and you don't want it to be bigger than 100k, that means that length of the piture field cannot be more than 136533 charaters (assuming UTF8).
1. Open the Data Source pane
2. Double-click on field1 to bring up its properties
3. In Validation, add a new condition
4. Select Expression, type this expression in: string-length(.) > 136533
5. Enter the text to be displayed when the error condition occurs
Now when you edit the form, if the image is too big, you will get an error validation and the user will be warned on save.
David Airapetyan / Software Services ArchitectQdabra® Software / Streamline data gathering to turn process into knowledge