If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Required Data Entry
Currently I have my code written so that if a field is left empty a message appears telling the user that they must fill in the field. The "requirement" comes from the on exit sub procedure.
The first five fields are "required" to be filled. The user can not go back and correct a mistake until the first five fields have been filled in. ie User is on answer four and they find out they made a mistake on answer two. The user must complete the five answers before entering control tab to go backward and correct mistakes. Is there some way that this can be overwritten on a temporary basis? I appreciate your help. Kenny G |
#2
|
|||
|
|||
Required Data Entry
"Kenny G" wrote in message
... Currently I have my code written so that if a field is left empty a message appears telling the user that they must fill in the field. The "requirement" comes from the on exit sub procedure. The first five fields are "required" to be filled. The user can not go back and correct a mistake until the first five fields have been filled in. ie User is on answer four and they find out they made a mistake on answer two. The user must complete the five answers before entering control tab to go backward and correct mistakes. Is there some way that this can be overwritten on a temporary basis? I would put this sort of validation in the BeforeUpdate of the form rather than OnExit of the controls. What if a required control never gets focus in the first place? In the BeforeUpdate of the form you can test all of the fields and display a single message indicating all of the problems. -- I don't check the Email account attached to this message. Send instead to... RBrandt at Hunter dot com |
#3
|
|||
|
|||
Required Data Entry
Rick,
Thanks for your reply. That's a great idea. Do I take each of those and put them on the before update in a Case If sub? If I have a message indicating there are some fields that need data entry - would it be possible to have the field turn red until the requirement is fulfilled? Thanks, Ken |
#4
|
|||
|
|||
Required Data Entry
"Kenny G" wrote in message
... Rick, Thanks for your reply. That's a great idea. Do I take each of those and put them on the before update in a Case If sub? If I have a message indicating there are some fields that need data entry - would it be possible to have the field turn red until the requirement is fulfilled? You can either have a series of If-Then blocks and produce a Message for each validation failure individually or (my preference) you can accumulate the problems and display a single message. Here is a sample of how I do that. Dim RqdMsg as string RqdMsg = "The Following Required Fields Were Left Blank." '(initially this variable has text that is 46 characters long) If IsNull(RequiredField1) Then RqdMsg = RqdMsg & vbcrlf & "Field1" If IsNull(RequiredField2) Then RqdMsg = RqdMsg & vbcrlf & "Field2" 'repeat as necessary If Len(RqdMsg) 46 Then MsgBox RqdMsg Cancel = True End if During the sequence of If-Thens you certainly could add code that changed the color of the control if you want. -- I don't check the Email account attached to this message. Send instead to... RBrandt at Hunter dot com |
#5
|
|||
|
|||
Required Data Entry
Rick,
Thanks for you prompt reply, I'll try this first thing in the morning. The more I know, the more I realize I don't know. Thanks Again, Kenny G |
#6
|
|||
|
|||
Required Data Entry
Rick,
Thanks again, it worked great this morning! Kenny G |
Thread Tools | |
Display Modes | |
|
|