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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox Criteria on LostFocus Event 1

Status
Not open for further replies.

rutkus

Programmer
Aug 28, 2001
41
0
0
US
In my form I have an InvoiceDate and ReceivedDate text box. In the ReceivedDate_LostFocus event I have this code:

If ReceivedDate < InvoiceDate Then
MsgBox &quot;Enter a Received Date that is later than the Invoice Date.&quot;
ReceivedDate.SetFocus
ReceivedDate.Text = &quot;&quot;
End If

The problem is that it doesnt keep the textbox focused. The msgbox comes out, it clears the textbox, but doesnt keep the focus on the textbox but jumps to the next one.

I dont think this should be an afterupdate event because if they dont change anything they could tab out the textbox.

Any and all suggestions are welcomed

HI-Priest
 
Something else along the same lines,

I have textboxes that appear only if a certain criteria is met, such as, if a certain choice from a combobox is picked.

I need to design it so if that textbox becomes visible then its a required entry, so if the user trys to tab out of it a msgbox or some kind of error wont allow them to.

Thanks
HI-Priest
 
Try after your message
me(&quot;ReceivedDate&quot;).undo
me(&quot;ReceivedDate&quot;).setfocus

jaz
 
that doesnt seem to change anything.

Thanks though, Jaz

I dont understand why it would move to the next textbox, is there anything inherent in the lostfocus event that would make it move to the next field?

Theres something really small that im overlooking, i can feel it. either that, or my whole approach to this is wrong.

HI-Priest
 
Why are you using lost focus? Why not use the BeforeUpdate Event then instead of using Setfocus use Cancel=True that event can be cancelled. Hence you stay in the object.

jaz
 
The reason I hesitated with the Before or After Update events is becaused I thought the user would still be able to tab out of the textbox once he gets the msgbox, as long as he didnt &quot;update&quot; the textbox.

Maybe I'm wrong about how these events worked, but I thought the before and after updates only get checked if the data in the textbox is changed.

HI-Priest
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top