Initialize text fields

  • Thread starter Thread starter Thomas Kroljic
  • Start date Start date
T

Thomas Kroljic

When a user enters data into a field on a form, there are times I need to
reset, re-initialize, or remove the value entered prior to saving the data
to the database using vba code. I'm not sure that I am going about it the
right way. I normally have to 1) ensure that the field (column) as the
"Allow Zero Length" set to true, and 2) using vba code I move "" to the
field.

Is this the correct, proper way to do this? If I do not set the "Allow Zero
Length" to true, I can not clear, or more "" to the field prior to saving
the record.

Thanks
Thomas J. Kroljic
 
How do you set the field to NULL?
If I try something like mField = Null, I get an error.

Thomas j. Kroljic
 
Is the field a Required field?

Are you trying to set a field's value or are you trying to set the value of
a control on a form to null?

On a form, I would try
Me.MyField = Null or
Forms!MyFormName!MyControlName = Null

IF this doesn't work, perhaps you could post the exact code you are using
and the event you are using.
 
<< Me.MyField = Null or
Forms!MyFormName!MyControlName = Null>>

John, is this the correct way to initialize a field or memory variable using
VBA code? For some reason, I have to use Me.MyField = "" to initialize a
field, especially if I am going to save the data to the table.

I just did a test and I think the reason I couldn't use the NULL value in
some cases was because the field was a required field. DUH.

Thanks for all of your responses.
 
Back
Top