A calculate button?

User avatar
Gasman
2StarLounger
Posts: 104
Joined: 22 Feb 2022, 09:04

Re: A calculate button?

Post by Gasman »

Forms("NameOfMainForm")!NameOfSubForm.Form.Requery
Hans, I would have to qualify that as

Forms("NameOfMainForm")!NameOfSubFormControlName.Form.Requery
though I know they can be the same name, but important to understand that it is the controlname that is required.

http://access.mvps.org/access/forms/frm0031.htm
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.

bknight
BronzeLounger
Posts: 1391
Joined: 08 Jul 2016, 18:53

Re: A calculate button?

Post by bknight »

HansV wrote:
12 Mar 2024, 10:30
I'd requery the form first, then perform the calculations.
If you want to requery another form than the form containing the button, use

Forms("NameOfTheForm").Requery

substituting the name of the form. If it is a subform, use

Forms("NameOfMainForm")!NameOfSubForm.Form.Requery
Re-query first will not include the values that are to be calculated. Please define SubForm. All I have is the table with 3 or 4 forms on the table.

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: A calculate button?

Post by HansV »

@Gasman: thanks for the clarification!
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: A calculate button?

Post by HansV »

@bknight: if you don't know what a subform is, don't worry about it.
Best wishes,
Hans

bknight
BronzeLounger
Posts: 1391
Joined: 08 Jul 2016, 18:53

Re: A calculate button?

Post by bknight »

I'm not worried, just wanted to know about it. Now there is a small issue:

Code: Select all

Forms("frmNinjaTrader2024_Apex").Requery
DoCmd.GoToRecord , , acLast
The form is re queried, no problem but As you may see, I would like the form to display the last record. This doesn't happen. Note the code resides on the form that contains the command button and this code is part of the On Click of that button. Since the code executes it seems as though the command button form goes to the last record.
What would be the code to have the form "frmNinjaTrader2024_Apex" go to the last record?

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: A calculate button?

Post by HansV »

Try

Code: Select all

Forms("frmNinjaTrader2024_Apex").Requery
Forms("frmNinjaTrader2024_Apex").SetFocus
DoCmd.GoToRecord , , acLast
Best wishes,
Hans

bknight
BronzeLounger
Posts: 1391
Joined: 08 Jul 2016, 18:53

Re: A calculate button?

Post by bknight »

As soon as I looked, I said to myself that will work, and it did work. Thanks