Test a field for error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I got a textbox1 that have as controlsource a field that is in a sub-form
If the sub-form is empty(no record added) my textbox will be #ERROR
If my textbox1 is <> #ERROR the value will go to another textbox2, else textbox2 =
Who do i put this in to code(event procedure)
 
You could use IsError() inside IIf() in the ControlSource of your text box.

The error generally occurs when there are no records in the subform and no
new ones can be added (like if the RecordSource is read-only, or the
subform's AllowAdditions property is set to No). In that case, the subform
goes completely blank and attempting to refer to the non-existent text box
throws the error.

One easy way around that is to set AllowAdditions to Yes, and cancel the
subform's BeforeInsert event. This allows it to show the new row (so the
text box is there and does not error), but prevents the user from actually
entering anything there.

Another alternative is to use a ControlSource like this:
=IIf([MySub].[Form].[RecordsetClone].[RecordCount]=0, 0,
Nz([MySub].[Form]![MyTextbox], 0))
 
Back
Top