David said:
I have a number of textboxes which may or may Not be Empty.
I don't use Resume Next
Is there anyway besides screening each field such as:
If Len(txtName.txt) > 0 Then
!fldName = txtName.txt
End If
to keep the ".Edit" or ".Add" from generating an error if the textbox
is Empty.
I think you must be talking about checking the .Text property, not .txt.
But you don't have to check the .Text property, which requires that the text
box have the focus. In principle, you can check each text box like this:
If Len(txtYourTextbox & vbNullString) > 0 Then
!fldName = txtYourTextbox
End If
Do I gather correctly that you are taking values from these text boxes and
using them to update a recordset? Knowing exactly what you are doing would
help in advising you.
The above code, you should be aware, will not modify an existing value in
!fldname if the text box is empty. Is that what you intended? You might
want the field value to be set to Null. If that's the case, you would have
to do something like this:
If Len(txtYourTextbox & vbNullString) > 0 Then
!fldName = txtYourTextbox
Else
!fldName = Null
End If
However, if you are dealing with required fields, you're going to get an
error if you try to save a record with a required field set to Null. More
information would be helpful.