Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing bound textbox causes it to lose entry

Status
Not open for further replies.

eksortso

Programmer
Jun 30, 2003
43
US
I am developing an ADP in Access 2003. I have a CustomersForm form, which is bound to an Customer table. The form is exhibiting bizarre behavior that I've never encountered before in any other Access-based app.

CustomersForm has an OnDirty event that updates a "Time Modified" field. But when this event fires, the form suddenly sets the focus on the current field, so that all of the text in the current field is replaced. I cannot even use F2 to edit the data in a textbox.

There is no code changing SelStart or SelLength on this form, and SetFocus is not being called. I've stepped through the execution of this form's code and realized that somehow, changing "Time Modified" is responsible for this sudden loss of text selection.

I've written many applications in the past, with similar OnDirty events, but this is the first time that this has happened. What can I do to allow editing of fields without clearing them?
 
Just a thought: why not using the BeforeUpdate event of the form instead of the Dirty ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I typically use BeforeUpdate on forms for validation only. There were times in the past when I tried changing data values in Form_BeforeUpdate(), but I got errors when I did that. That was due either to bad coding (this was many years ago), or to erratic behavior in Access, which makes it nearly impossible to code against.

Anyway, I took your advice, and right now, everything seems to be working well. Thanks, RoyVidar and PHV.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top