robinski
10-21-2001, 02:55 PM
Greetings,
I have a text field which is a required field.
It is marked 'required' in the table properties. This causes the error message to appear when attempting to leave the record. I need the error message to appear when leaving the field. I have read the 'help'
explanation but cannot understand what they are trying to tell me.
Your ideas will be appreciated.
robinski
Dave Sherer
10-21-2001, 05:11 PM
you can try this on the Lost Focus Event
If IsNull(Me.TextBox) Then
MsgBox "Need To enter Data Here in this field",, "Need Data"
Me.TextBox.SetFocus
End If
This will check if there is data in that required field once it has left lost focus on that field. This Will not on the other had check vor validation of the data. But you can probally work that in with more code.
HTH
Pat Hartman
10-21-2001, 07:58 PM
The correct place to put the null check is the FORM's BeforeUpdate event. The field's LostFocus event would only accomplish the purpose if the cursor were actually placed in the field. If the field is never entered, the LostFocus event would never be executed. One additional statement is necessary to complete the edit. You also need to add the following in the If statement -
Cancel = True
This statement will cancel the update event and prevent Access from attempting to save the record when the required field is null.
robinski
10-21-2001, 08:54 PM
Thanks guys, this is my first query. Is it usual to acknowledge the help? Is it OK to send an email direct with "Thank You" ?
I do understand you do not wany questions direct.
Cheers,
Robinski
robinski
10-21-2001, 10:51 PM
I have now added your suggested code to the application and it works as I had hoped with the exception that I would prefer the focus to return to the original field.
Thanks
robinski
SteveA
10-22-2001, 04:16 AM
If you want to place the cursor at a specific field on a form, try Me.[MyField].SetFocus
HTH
Steve
Maybe my version of access, but I could never get Me.[MyField].SetFocus to work, but MyField.SetFocus does.
HTH
robinski
10-22-2001, 12:52 PM
I am still getting the cursor go to the [Analysis] field but then go straight to the next field in the tab list.
Thanks,
robinski