Easy Forms Questions

A

AJ

I have a form that I setfocus to a text box upon opening the form. Is there a
way to force the user to update that field before I allow them to navaigate
away from it?
 
T

Tom Ventouris

If the field is empty when opening the form:
Yes, OnLostFocus event to go back to that textbox if it is Null or ""
(depending on the format).
You can also add a message to alert the user that they cannot leave the
field until it is updated.

If not empty, what are you storing in it?.
This will help with further suggestions.
 
A

Arvin Meyer [MVP]

Sure disable all the other controls on the form's property sheet, then in
the AfterUpdate event of the control you want, re-enable them (aircode):

Sub txtMyControl_AfterUpdate()
Me.text2.Enabled = True
Me.text3.Enabled = True
Me.text4.Enabled = True
' etc.
End sub

You will need to also enable or lock, the next control in the tab order, or
you won't be able to move off of the focused control. I'd lock it, but
there's no visual cue if you do. If you choose to enable it, there's still
no visual cue, but you can write some code in the OnGotFocus or OnEnter
event to tell the user to go back and do the first control.
 
S

Stefan Hoffmann

hi AJ,
I have a form that I setfocus to a text box upon opening the form. Is there a
way to force the user to update that field before I allow them to navaigate
away from it?

Option Compare Database
Option Explicit

Private m_DataChanged As Boolean

Private Sub txtField_BeforeUpdate(Cancel As Integer)

m_DataChanged = (txtField.OldValue <> txtField.Value)

End Sub

Private Sub txtField_LostFocus()

If Not m_DataChanged Then
MsgBox "Change your data."
End If

End Sub

Private Sub Form_Load()

m_DataChanged = False
txtField.SetFocus

End Sub


mfG
--> stefan <--
 
S

Stefan Hoffmann

AJ said:
I have a form that I setfocus to a text box upon opening the form. Is there a
way to force the user to update that field before I allow them to navaigate
away from it?
Use

m_DataChanged = (IsNull(edtValue.OldValue) And Not edtValue.Value) _
Or (edtValue.OldValue <> edtValue.Value)

as criteria in the BeforeUpdate.


mfG
--> stefan <--
 
Top