Hello,
I'm using a Microsft Access 2000 Project (adp file) connected to MS SQL Server 2000 database.
I have created a continous form having a detail part (results of the query) and a footer part (aggregate functions).
My problem concerns the sub-totals calculated in the footer part that are not updated when the results are filtered in the form.
For exemple, if we have the following results
ID City Country Population
1 Paris France 2.100.000
2 New-York USA 8.100.000
3 Marseille France 800.000
The sub-total calculated is 11.000.000 which is correct.
However, when I filter the results in the form to the country "France" (right filter by selection), the sub-total calculated is still 11.000.000 which is wrong. :confused:
Anyone have the same problem ?
Anyone having an idea ?
I have tested this functionnality with a Access database (.mdb file) and the sub-total is correctly updated when the results are filtered. :eek:
Why a different behavior between an "adp" and a "mdb" file ?
Anyone having an idea to get the correct sub-totals with filtered results ?
Thank you for your help.
Terrybens
Jul 17 '06
13 11274 PEB 1,418
Recognized Expert Top Contributor
And maybe you can Requery all your form, using commands like:
Me.Requery
Me.Refresh
Me.Repaint
docmd.showallre cords
You can see more info in Access help for those methods!
Hi,
I'm struggling with the same problem now. What kind of code did you enter at the "apply filter" event?
Thanks,
Lana
Thank you comteck for your reply.
I cannot use "sum" in the source of my form because the form displays a list of results while a "sum" function in a query will return an aggregated line.
I can however calculate the sub-total in another query using VBA code, which is your solution I guess. On the event "apply filter" of the form I can run a piece of code to calculate the sub-total.
I have tried this but the sub-totals fields in my footer are in "read only" because I have not specified a unique table in my form. However I cannot choose one (nothing in the listbox) because my record source is proc stock.
I have no idea how to solve this problem.
Thank you guys for your help.
Terry
Hello,
I come back on this subject more than 3 years after the last post, because I want to share my solution to this problem with anybody facing it, and because I didn’t find a full working solution anywhere in the web.
I have an Access project (ADP) using SQL Server 2005.
I have some statistics forms that are doing parameterized query, build specifically responding to forms controls. So, I can’t use a SQL Server view as a source for my form.
A first idea was to use SQL Server temporary table, to respond a Microsoft support article saying that sum can’t be done on calculated fields. This had for effect to make sum TextBox in footer working (no more #Error). But, unfortunately, when applying an Access filter, sums where not actualized, even with a Requery.
The second thing was to use the Form_ApplyFilte r, to pass the local Access filter to Me.ServerFilter . And it’s works!
Here is bellow a summary of my code.
Very important: As Access can’t run more than one instance of a form, using a temporary table (in my code bellow, named #myTemporaryTab le) will not be a problem. But, if you have to use this technique in more than one form of you application, be careful to use different names in each form for your temporary table. To avoid any problem, I use the form name, followed by “Data”, and of course prefixed by # (this is mandatory).
Also, note the closing of this temporary table, in Form_Close, but also just before to create it, just to be sure to avoid any error.
In Form_ApplyFilte r, note the substitution of double cote by simple cote, and also the transformation of the access alike word in standard SQL like word. -
-
‘ Opening form
-
Private Sub Form_Open(Cancel As Integer)
-
…
-
LoadStatRecordSet
-
End Sub
-
-
Private Sub Form_Close()
-
globalConnexion.Execute "IF OBJECT_ID('tempdb..#myTemporaryTable’) IS NOT NULL DROP TABLE #myTemporaryTable’"
-
End Sub
-
-
‘ This Sub construct the query based on user inputs, and open a SQL temporary table
-
‘ This SQL temporary table is private to user connexion, so no problem for multi users.
-
‘ note: globalConnexion is your ADODB.Connection to access SQL Server
-
Private Sub LoadStatRecordSet()
-
Dim strSql As String
-
-
strSql = "SELECT <here, your fields>
-
"INTO #myTemporaryTable " & _
-
"FROM <here, your source tables with join>" & _
-
"WHERE <here, your conditions, May responds to user inputs>"
-
strSql = strSql & " ORDER BY <here, your fields for sorting> "
-
-
globalConnexion.Execute "IF OBJECT_ID('tempdb..#myTemporaryTable’) IS NOT NULL DROP TABLE #myTemporaryTable"
-
globalConnexion.Execute (strSql)
-
-
Me.RecordSource = "#myTemporaryTable" ‘ a SELECT * FROM #myTemporaryTable doesn’t works !
-
-
End Sub
-
-
-
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
-
On Error GoTo Form_ApplyFilter_Err
-
-
If ApplyType = 1 Then 'If a filter is being applied...
-
Me.ServerFilter = Replace(Replace(Me.Filter, """", "'"), "Alike", "Like") 'Replace double-quote (") with single-quotes (')
-
Else 'The filter is being un-applied so remove it from the server filter.
-
Me.ServerFilter = ""
-
LoadStatRecordSet
-
End If
-
Me.Requery
-
-
Form_ApplyFilter_Done:
-
Exit Sub
-
-
Form_ApplyFilter_Err:
-
<here, your code to inform user, log error…, like a msgBox or anything else)
-
Resume Form_ApplyFilter_Done
-
-
End Sub
Hope this can help you!
MMcCarthy 14,534
Recognized Expert Moderator MVP
Thanks for posting your solution. It's much appreciated.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: kackson |
last post by:
Hi.
I would like to access my database outside of my company. I read many
documents but they are all pertaining to accessing the database via
ASP or some form of web application. Is there no single windows or
linux application tht runs natively to access a remote SQL data base?
Any advise is appreciated. Thanks!!
|
by: rickcheney |
last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I
had a form where the user entered a value into a text box and when a
command button on the form was clicked a Report was opened. The reports
record source is a query. The query uses the value from the form text
box to restrict the query.
Table name = EggsTable
one of the columns in the table is named: EggColor
Form name = EggColorForm
Form text box name = ColorTextBox
|
by: damjanu |
last post by:
Hi All;
I need little help.
I have a datasheet form.
I allow user to do 'filter by selection'.
My form contains a column with values.
As user changes selections, I want to
calculate totals. I can do this the
first time the form loads.
|
by: M. Farrenkopf |
last post by:
I am in the process of converting a Jet database to ADP using SQL
Server 2000. Most of this conversation has been smooth, but now
I'm running across a problem that has me stumped. Access 2000 SP3 on
Windows 2000 Professional. I'm not in charge of the SQL server, so
I don't know its OS (presumably irrelevant). Presumably, it's been
updated with its latest service packs. With this conversion, I'm
moving everything on the VB side from...
|
by: Malcolm Cook |
last post by:
I've discovered:
Using "File > Print Preview" in a form's datasheet view with a server Filter
crashes access after previewing...
....that is, unless ServerFilterByForm has been turned off after applying the
filter.
See the steps to recreate bug below for details.
| |
by: Greg Strong |
last post by:
Hello All,
Hello All,
What are the ToDo's / Gotchas to convert an MDB Access 2K2 database to
an Access Project (i.e. ADP) file for the front end using Microsoft
SQL Server 2000 Desktop Engine (MSDE 2000) for the back end?
Now for the background. I have a prototype MDB file that was built in
Access 2K2, and compiled in Access 2K to provide backward
|
by: ken |
last post by:
Hi,
Lets say we have a form that displays time card entries based on the
calendar control date on the form. So the user clicks on a date and the
form filters the table where the time card entries come from to get you
proper data.
In access I would just filter the query(rewrite its qrydef) and I'd get
my answer.
My question is, what is the proper way of doing this in ADP and SQL
Server 2005. I could filter the data from the view on the...
|
by: Allen Browne |
last post by:
If you are looking for opinon on what's useful in Access 2007, there's a new
article at:
http://allenbrowne.com/Access2007.html
Covers what's good (useful features), what's mixed (good and bad), what's
gone (features removed), what's fixed (old issues solved), what's broken
(new bugs), configuration, compatibility, should you buy, and links.
It is opinion, so you may disagree, but hopefully it's an informative
summary.
|
by: elias.farah |
last post by:
Hello Everyone,
I'm having some very weird behavior on a couple of Access forms. (Not
all forms, just some of them).
The forms have been working for years, under Access XP/2003 etc, and
last week upgraded from Windows XP/Office 2003 to Vista x64/Office
2007.
Under Access 2007, a couple of forms are now taking 60 seconds to
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |