Solved OnExit or Lost Focus for TextBox in Subform (1 Viewer)

mfaisal.ce

Member
Local time
Today, 17:03
Joined
Dec 21, 2020
Messages
76
Hello Dears,

I have a subform and a column "Discount" and i have some code on OnExit event for Column "Discount" and it works fine, but when i click out of subform then the event OnExit does not triggered?? can u explain what is the reason and how to solve the issue.....

regards,
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:03
Joined
May 21, 2018
Messages
8,527
That should not be the case, should happen any way you exit. Can you provide the actual code? What happens if you do lostfocus instead of exit?
 

mfaisal.ce

Member
Local time
Today, 17:03
Joined
Dec 21, 2020
Messages
76
That should not be the case, should happen any way you exit. Can you provide the actual code? What happens if you do lostfocus instead of exit?
dear i tried with LostFocus also but same problem.... i am sharing my database file,

Form : Sales
Subform : Sales Detail
column : Discount
Problem... OnExit or Lostfocus doesnot work when i click outside the subform even pointer is on Discount column...
 

Attachments

  • Ali Shop[Temp].accdb
    1.8 MB · Views: 120

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:03
Joined
May 21, 2018
Messages
8,527
I see the issue, not sure of the cleanest solution
It works if you click out of that cell in the current form. My guess you are clicking outside the form, so the when you leave the sales form for another form it remaines in the discount cell on the sales form.

I am thinking when you enter another form you want to requery the sales form which should fire the exit event. You may have to set it "dirty = false" first.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:03
Joined
May 21, 2018
Messages
8,527
I am no expert on is Inventory and sales database. A lot of people are, but when I look at your tables this does not look correct to me. This looks like a lot of duplicated non normalized data. Why are you saving any totals, subtotals and then passing that to a payment table. Again this is not my strong suit, have others chimed in?

I looks like me that you create a group of sales for a given SRNo. That should record date, item, quantity, and discount. All totals are calculated. Then payments is linked to the group of items sold. I do not understand why any calculated information would ever get passed to the payment tables.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:03
Joined
Feb 19, 2002
Messages
43,257
Since you want the code to run whenever the record has been updated, move the code to the FORM's BeforeUpdate event and remove the save command. Access automatically saves the dirty record when you leave the record no matter how you do that.
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:03
Joined
May 21, 2018
Messages
8,527
That is a good point the before update does not care if you leave the control. However, I still think there is bigger issues.
Example 1. Add a sale.
2. Click into the payments on a new record
3. Add a new sales

At least set the allow additions to false on the payments.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 15:03
Joined
Sep 12, 2006
Messages
15,650
I don't a think a control's on exit will fire unless you enter the control. Simply closing or leaving the form won't cause the event to fire.
What are you actually trying to do?
 

Users who are viewing this thread

Top Bottom