Question Totals in a datasheet (1 Viewer)

munhun

New member
Local time
Today, 01:16
Joined
Nov 23, 2018
Messages
8
Hello.
Help me.

Click the "Home" tab -> Record -> Total to get the sum in the datasheet.

I want to implement this menu button with vba.
What is VBA code?

ex) docmd.RunCommand ????

I would appreciate your reply by e-mail.
jeongmunhun
@ gmail . com

Thank you.
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 01:16
Joined
Oct 29, 2018
Messages
21,542
Try.

CommandBars.ExecuteMso "RecordsTotals"
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:16
Joined
Feb 19, 2002
Messages
43,484
If you are using a newer version of Access, you can embed totals in the datasheet itself. No code is required. Just use the Totals button and pick the type of aggregation by choosing from the dropdown under each column. What version of Access are you using?
 

munhun

New member
Local time
Today, 01:16
Joined
Nov 23, 2018
Messages
8
CommandBars.ExecuteMso "RecordsTotals" ... Good code.

But....
One more question.

Do you know if "RecordsTotals" is displayed or not?
I want to show when a record is present and not when it is not.

It is causing problems when there are no records.

 

Attachments

  • 1.jpg
    1.jpg
    104.2 KB · Views: 93
Last edited:

Galaxiom

Super Moderator
Staff member
Local time
Today, 18:16
Joined
Jan 20, 2009
Messages
12,856
In my experience, the display of Totals in datasheets can be a bit flaky especially when filtering.

If I use a datasheet I usually put the total expression as the ControlSource of a textbox in the header or footer. The header or footer won't display but it can be referred to from other objects.

Put the datasheet in a subform and refer to it from a control on the main form.

This technique works in all version of Access.
 

munhun

New member
Local time
Today, 01:16
Joined
Nov 23, 2018
Messages
8
Even if it's not a good idea...

When there is no record "SourceObject = ''"

form_name.SourceObject = ""

Thank you...
 

Users who are viewing this thread

Top Bottom