473,545 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb help in Ms Access: combining selection and group by total

2 New Member
Hi there,

I am trying to do a similar thing here with access n vb but with a few additions. Please take a look.

I have a table that looks like this:

ID Product Total
1 aaa 10
2 aaa 19
1 bbb 2
3 aaa 1
2 bbb 3
1 ccc 9
3 bbb 3
...& so on

the ID identifies which month it is.

What i am trying to do is to be able to choose which month (ID) i want say '1' and '3'
and it will hopefully give me a grand total of:

aaa 11
bbb 5

im a real newbie and i have tried changing codes that have been posted here but so far no luck


Big Thanks in advance :)

Matt
Apr 15 '08 #1
2 1298
testar
2 New Member
Lol put in a bad intro. i was going to post a reply post to one of the discussions but i thought otherwise so i just copy/paste into a new post without changing the opening sentence. sorry folks.

Matt

Hi there,

I am trying to do a similar thing here with access n vb but with a few additions. Please take a look.

I have a table that looks like this:

ID Product Total
1 aaa 10
2 aaa 19
1 bbb 2
3 aaa 1
2 bbb 3
1 ccc 9
3 bbb 3
...& so on

the ID identifies which month it is.

What i am trying to do is to be able to choose which month (ID) i want say '1' and '3'
and it will hopefully give me a grand total of:

aaa 11
bbb 5

im a real newbie and i have tried changing codes that have been posted here but so far no luck


Big Thanks in advance :)

Matt
Apr 15 '08 #2
JustJim
407 Recognized Expert Contributor
Lol put in a bad intro. i was going to post a reply post to one of the discussions but i thought otherwise so i just copy/paste into a new post without changing the opening sentence. sorry folks.

Matt
Hi Matt,

First of all, perhaps ID is not the best field description for a field which represents months.
Anyway... Air code follows (I'm on a train and can't check the code in Access just now)

Expand|Select|Wrap|Line Numbers
  1. SELECT Product, Sum(Total) as GrandTotal
  2. FROM YourTableName
  3. WHERE ID = 1 or ID = 3
should do the trick. Of course it would be more elegant if you work towards letting the code know what months you want before it runs.... but that's another lesson.

Jim

PS I can't help thinking that a GROUP BY clause would be required here. Try it in query design mode and then check the SQL view.
Jim
Apr 15 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
6266
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.
11
4032
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it again, Excel hangs. OR if I open Excel again (say from a desktop icon) before I close Access, Excel hangs. (this has happened for both 97 & 2000...
3
3408
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am working on. I am working with MS Access 2002. And I am having a problem with one of my charts. I will explain how everything is laid out then go...
1
1828
by: BeanCounterCPA | last post by:
OK, I'm sure there is an easy way to do this, but I am just a novice at Access and can not find a solution. I have a database that I used to pull a confirmation sample from by using dollar unit sampling. The selection works just fine, however, when I finish doing the selection I want to resort the database in account number sequence and then...
4
12418
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
4
1932
by: pokerboy801 | last post by:
OK, I will try to explain this as clearly and as concise as possible. I am using Access, which has three MS Excel Linked tables, to store call center metrics for reps. My Excel workbook has three separate worksheets, all linked to Access. I have a query that performs some minor calculations, not to hard, and will be ued to drive a report....
0
7648
MMcCarthy
by: MMcCarthy | last post by:
Rather than using the Access design view change the view to SQL. I am going to attempt to outline the general syntax used for SQL queries in Access. Angle brackets <> are used in place of some syntax elements you must supply. The description of these elements will be in the contained in the angle brackets. Square brackets are used to show...
4
2612
by: dsdevonsomer | last post by:
Hello, I have one simple query joining two tables with left outer join on 3 fields and using MIN on two fields. These two tables have lot of data about 3 mil in total. I am trying to migrate db from MS Access to SQL 2005. I get about 689000 rows in SQL Server, vs 863000 rows in MS Access. SELECT T1., T1., T2., MIN ( T1.), MIN(T1. ),...
1
4731
by: annemariearmour | last post by:
I am using Crystal reports version 11.2 to create reports. The data source is SQL Server, and I am using views rather than reporting directly from tables. I apply selection criteria to the incoming records at record level and at group level. For example, I may select all bill lines with a receipt date within a certain date range. This results in...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7682
Oralloy
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. ...
1
7449
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...
0
6009
agi2029
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...
1
5351
isladogs
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...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
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...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.