How to ensure unbound text box does not remain null

P

Pete

How can you ensure an Unbound text box in a Form has some data written into
it before it is closed i.e. an entry is required? Some enlightenment would be
much appreciated.
 
R

Rob Parker

Hi Pete,

If it's an unbound textbox, it's up to you (as the programmer) to decide how
to treat any entry in that box. You can't use the BeforeUpdate event of the
form itself (the normal way of doing any validation not already enforced by
rules on the underlying table) since that only applies to bound fields. And
further, if the control is not bound to any underlying field, what would be
the point - any data entered is not going to be saved.

Your question seems rather pointless - perhaps you could elaborate further
and someone may be able to help more.

Rob
 
S

Stefan Hoffmann

hi Pete,
How can you ensure an Unbound text box in a Form has some data written into
it before it is closed i.e. an entry is required? Some enlightenment would be
much appreciated.
Does this makes sense? You may use the Form Unload event:

Private Sub Form_Unload(Cancel As Integer)

Cancel = (Len(Trim(Nz(yourTextBox.Value, ""))) = 0)

End Sub



mfG
--> stefan <--
 
P

Pete

Thanks, I have used the idea you have given me, and now a message appears
when the record is saved if the textbox has remained Null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top