'not in list' event not catching tab or enter

  • Thread starter Thread starter tlyczko
  • Start date Start date
T

tlyczko

I have this code for validating a not in list event, combo box IS set
to limit to list.

User hits tab or enter, no errors get generated, why???

'6/27/05 determine whether to add it to the list
If MsgBox("The value you just entered (" & NewData & ") " & _
"is not in the list. Do you want to add it?" & vbCrLf & vbCrLf &
"Please be sure before you add it." _
, vbQuestion + vbYesNo, "Add to list?") = vbNo Then
'DON'T add it ... go to exit label
Response = acDataErrContinue
GoTo Exit_txtName_NotInList
Else 'DO ADD it to the dropdown list
If IsNull(NewData) = True Or NewData = "" Or Len(NewData) < 1 Or
InStr(NewData, ", ") < 1 Then
Call MsgBox("Please enter a new name in the format 'Last, First' in
the Name: field.", vbExclamation Or vbSystemModal, "Required Data
Entry")
Response = acDataErrContinue '6/27/05 don't proceed further
GoTo Exit_txtName_NotInList
End If
'from here onward go to adding name to the database table

My problem is that the user can easily hit tab or enter and NOTHING, no
error messages come up, how do I fix this, do I test for tab and enter
in the key down event????

Thank you, Tom
 
Hi Tom

The NotInList event is intended to detect the user *typing in a value* which
is not in the list. Merely visiting a control and then leaving it again
does not count as typing in a value.

You could use the combo box's Exit event to check that a value has been
entered, but this might cause frustration if the user wants to close the
form and an item has not been selected. Besides, the user could presumably
use the mouse to navigate to another control, so that your combo box is
never visited.

A better solution would be to check for a Null value in the form's
BeforeUpdate procedure.
 
Hello Graham,

Thank you for answering. I tried the BeforeUpdate and testing for Null
in that event for the txtName control, but that did not work, whereas
the Exit event for the control works, like you said it would. I may
leave that as is.

Now all I have to do is test all the important controls on the form in
the form's BeforeUpdate event like you said, so I will do that. Certain
data on the form is important enough to check it twice to be sure it is
entered. Some table values are set to Required=True and I don't
presently know if I could change that easily, I didn't know enough
about NotInList etc. when I designed this database and form, sigh.

Thank you, Tom
 
Hi Tom

I said the BeforeUpdate event of the *form*, not the textbox control. The
latter event will only fire if the *control* has been updated.

It's fine to set the Required property for certain fields, *and* to check
for data in Form_BeforeUpdate. It's the "belt and suspenders" approach, and
besides, it allows you to give the user a nice, friendly message before
Access butts in with its confusing, unhelpful one :-)
 
Back
Top