refreshing a field on a form using VB or protecting a field from u

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

Guest

I'm trying to add logic to my VB code to not allow changing of a field (for
example, an existing order number). I added logic in VB code of the Before
Update event, that if something exists in that field already, the VB code
displays a message saying it can't be changed, and I saved the original value
of what was in their before they edited it, but I can't figure out how to put
that original value back in. Only on new orders should the user be able to
enter a value in the field. For existing orders, the order number should be
not editable.
 
I would code the on current event so the field can't be edited if there is an
existing value. ie.
if me.fieldname is not null then

fieldname.locked = true

else

fieldname.locked = false

THis is untested and may need to be tweaked.
end if
 
One way that will get the job done is to set the control's Enabled
property Off. Then, in the form's OnCurrent event, test the control's
value for null. If it is null then MyControl.enabled = True. Else
MyControl.enabled=False

Once the record is saved with a non-null value the control will be
disabled.

You may want to make that one control Bold so the number is still easy
to read.

HTH
 
Back
Top