473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to use group by method in vba code

dim section as string
dim admn as number
dim name as string
dim roll_no as number

table

rooll_no admn name section
1 --------- 99 ---- abc ---- a
2 --------- 100 ---- def ---- a
3 --------- 101 ---- ghi ---- a
1 --------- 102 ---- abc ---- b
2 --------- 103 ---- def ---- b
3 --------- 104 ---- jkl ---- b
1 --------- 107 ---- mno ---- c
2 --------- 109 ---- klm ---- c
4 --------- 111 ---- nok ---- c

this is table

so i want do a coding in vba using group by method
because
there is three sections a,b,c so
i like to generate section wise roll number
so please give me exampe
Jun 10 '10 #1
1 3627
MMcCarthy
14,534 Expert Mod 8TB
If I understand what you are asking correctly. You want to create the next roll_no based on each section.

Firstly, as these are fields in your table you don't need to create variable names for them. You need to build a query using recordsets in vba.

Check out this article on using recordsets.

Your query would need to be something like ...

Expand|Select|Wrap|Line Numbers
  1. SELECT Max([Roll_No]) As MaxRollNo 
  2. FROM TableName
  3. WHERE Section='a';
You could then set the next Roll_No for that section to MaxRollNo + 1
Jun 11 '10 #2

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

Similar topics

3
by: news.onetel.net.uk | last post by:
I and my friend Karl have spent literally all day trying to find out what is causing my error but we are zapped of any further functionality :) I have a form that adds news records. You select...
5
by: Sarir Khamsi | last post by:
I have a class (Command) that derives from cmd.Cmd and I want to add methods to it dynamically. I've added a do_alias() method and it would be nice if I could turn an alias command into a real...
4
by: Danny | last post by:
I have this bit of code: SELECT itemcode, min(Price) AS minprice FROM itemlist GROUP BY itemcode; it lists the minimum price for each itemcode group. It works fine. But when I want to see...
0
by: henry fung | last post by:
Hi, How do you create a shoutcut to a table in an existing group using code only in Access 2003. The closest I can do is to create a shoutcut to a selected object to a new group using:...
0
by: Mark Broadbent | last post by:
Could someone who has active experience of assigning Security Policys please clarify my follow comments... Having gone through the MSDN documentation on this subject, my condensed version of the...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
3
by: Dave | last post by:
This code generates the following error: Error 2 Cannot convert type 'System.Collections.Generic.KeyValuePair<string,CollectionTest.Group>' to 'CollectionTest.Group'...
0
by: Scott | last post by:
Google VB Code Group Group name: VB Code Group home page: http://groups-beta.google.com/group/vb-code?hl=en Group email address vb-code@googlegroups.com
2
by: vksundari | last post by:
I am executing a select query in a C# component and populating a ASP Grid in Search.aspx. Now one of the columns in the Grid in Search.aspx is Policy Number(hyper link) Basicallly I want to call a...
0
by: serhio | last post by:
Hello, I have a problem with Microsoft.Office.Interop.Excel.Range.Group() method. The problem is that I can call this method only 7 times, before it throws me an exception. I don't...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.