Required Field Problem

D

DEI

I have a form with several required fileds (set with the property in the
underlying table). One filed is a drop down list. If the user does not find
it in the list, he/she will have to add the value to a lookup table so it is
available for them to use when creating a new record.

So a user begins to type in a new value, and the autocomplete does not grab
any existing values. Fine. Or the user tried to tab off the field and gets a
'Not In List' error dialogue - fine also. But when the user backspaces or
deletes the text they have been typing, after realizing it is not in the
list, and tabs or licks off the field, the 'required field' error occurs.

I am open to a new approach if this type of validation strategy seems
problematic.

Thanks in advance.

DEI



Is there a way for me to test whether a filed has been typed into yet?
Similar to finding out if the 'Before Insert' event has occurred - so the
user can delete any text they have typed and move off the field? I would be
able to
 
D

Dirk Goldgar

DEI said:
I have a form with several required fileds (set with the property in the
underlying table). One filed is a drop down list. If the user does not
find
it in the list, he/she will have to add the value to a lookup table so it
is
available for them to use when creating a new record.

So a user begins to type in a new value, and the autocomplete does not
grab
any existing values. Fine. Or the user tried to tab off the field and
gets a
'Not In List' error dialogue - fine also. But when the user backspaces or
deletes the text they have been typing, after realizing it is not in the
list, and tabs or licks off the field, the 'required field' error occurs.

I am open to a new approach if this type of validation strategy seems
problematic.

Thanks in advance.


What the user *should* do, though you may have to instruct them to do it, is
press the Escape key to clear their entry in the field. If you really need
to, you can probably put code in the control's Change event to check whether
the user is trying to clear their entry in a previously empty field, and
undo it if so -- along these lines:

'----- start of air code -----
Private Sub YourCombo_Change()

If Len(Me!YourCombo.Text) = 0 Then
If IsNull(Me!YourCombo.OldValue) Then
Me!YourCombo.Undo
End If
End If

End Sub
'----- end of air code -----
 
D

DEI

Thanks - that code seems to work well. I am still unclear on all the events
related to forsms and controls, i.e. when they occurr. I would not have
thought to use the 'On Change' event.
 
D

Dirk Goldgar

DEI said:
Thanks - that code seems to work well. I am still unclear on all the
events
related to forsms and controls, i.e. when they occurr. I would not have
thought to use the 'On Change' event.


Depending on which version of Access you're using, you may find it easier or
harder to locate the appropriate help topic in the online help. See what
you can get by entering "events" in the search-help box, or go to the table
of contents and look for Events under "Microsoft Access Visual Basic
Reference".

For a text box or combo box, the Change event fires whenever the displayed
text changes due to user action. That means that it fires for each
character you type in the control, or when you use the backspace or delete
key to remove characters.
 

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

Similar Threads


Top