ms access Query to run automatically after a value is filled in a field (1 Viewer)

sibbbra

Member
Local time
Today, 12:13
Joined
Feb 11, 2022
Messages
78
hii have attached a db. in all customer orders form, i want that whenever Rate is inserted and toatal i s automatically calculated, then the field Net_Amount_Cus ,s value be automatically inserted into the Amount_Sale filed. means query C_Add_Amount should run automatically.
how would i do that
 

Attachments

Probably should not save this calculated value - calculate when needed. Saving aggregate data is usually a bad design.

Query works. Just have to figure out what event to call it from. Possibly from [frm line total sale] AfterUpdate.

Strongly advise not to use space in naming convention.
 
Last edited:
no help yet
 
What do you need? Do you know how to run a query from VBA?

DoCmd.OpenQuery "C_Add_Amount"
 
What do you need? Do you know how to run a query from VBA?

DoCmd.OpenQuery "C_Add_Amount"
Thanx
I want that the field 'Net_Amount_Cus' value be automatically inserted into the 'Amount_Sale' filed. means query 'C_Add_Amount' should run automatically, when values are entered into Rate field
 
I provided you sample code to do that and a suggestion for where to run it. Did you try?

Can't run it when value is entered into Rate field because the total does not calculate until record is committed to table.

As I already said, this is really not a good idea.
 
I provided you sample code to do that and a suggestion for where to run it. Did you try?

Can't run it when value is entered into Rate field because the total does not calculate until record is committed to table.

As I already said, this is really not a good idea.
Ok . If line total filed is calculated, then how to do same next?
 
you can also add code to the Subform's AfterUpdate event and Current event.
 

Attachments

you can also add code to the Subform's AfterUpdate event and Current event.
but gives error when new form entry to be made. see in attachment.
 

Attachments

  • 1671521403740.png
    1671521403740.png
    180.6 KB · Views: 128
Well, darn, won't work anyway. The query runs before the textbox shows recalculated value. Afraid I am not going to try to advise on this any more because it's a bad idea altogether.
 
just add an Expression to your Balance.
 

Attachments

You don't really need a query.
Just set the display field to a formula something like

=NZ(quantity,0) * NZ(price,0)

It will update automatically when it has usable values in those fields. You only need code if the formula is not so simple.
 

Users who are viewing this thread

Back
Top Bottom