I have a Table (Table01)in Access with one number field name Num (double)
I want a routine to create a new table ex.Table02 with 2 fields the first
with combinations and the 2nd with the sum of the combinations
Example:
Table01
NUM
1
2
3
Table02
Field01 Field02
1 1
2 2
3 3
1,2 3
1,3 4
2,3 5
1,2,3 6
Thanks,
Sotiris
3 1265
It seems interesting.
i'll give it a try with arrays: lets say your table is called Table1 and is a doubles array. and lets make Table2 an strings one 'cause we are writing numbers and commas: - Dim Table2() As String
-
Dim TmpDou As Double
-
Dim i() As Integer 'hoping you table has less than 32000 elements
-
Dim j As Integer
-
Dim n As Integer
-
Dim k As Long 'this will be for counting the combinations
-
Dim Boo1 As Boolean
-
TmpDou = UBound(Table1) - LBound(Table1) + 1 'The number of elements in table1
-
TmpDou = 2 ^ TmpDou - 1 'the number of combinations excluding the empty one
-
ReDim Table2(1 To TmpDou, 1 To 2) 'this will be our working space
-
ReDim i(1 To TmpDou) 'this will be for counting
-
'In case your indexes doesnt start at cero:
-
-
n = 1
-
Do
-
If n > UBound(Table1) - LBound(Table1) + 1 Then Exit Do
-
ReDim i(1 To n)
-
For j = 0 To n - 1
-
i(j + 1) = LBound(Table1) + j
-
Next
-
Do
-
k = k + 1
-
TmpDou = 0
-
For j = 1 To n
-
Table2(k, 1) = Table2(k, 1) & Table1(i(j)) & ", "
-
TmpDou = TmpDou + Table1(i(j))
-
Next
-
Table2(k, 1) = Left(Table2(k, 1), Len(Table2(k, 1)) - 2)
-
Table2(k, 2) = TmpDou
-
i(n) = i(n) + 1
-
If i(n) > UBound(Table1) Then
-
j = n - 1
-
i(n) = UBound(Table1)
-
Do
-
If j = 0 Then
-
Boo1 = True
-
Exit Do
-
End If
-
If i(j) < i(j + 1) - 1 Then
-
i(j) = i(j) + 1
-
i(j + 1) = i(j) + 1
-
Exit Do
-
Else
-
j = j - 1
-
End If
-
Loop
-
End If
-
If Boo1 = True Then
-
n = n + 1
-
Boo1 = False
-
Exit Do
-
End If
-
-
Loop
-
Loop
I think there's an easier way, but this one works
Thank you for the reply,
is that possible to create this code in Access database (mdb) file,
with one table with the number for combinations, 2nd table with the
results and a form with the button than will run the code.
Thans Sotiris
Thank you for the reply,
is that possible to create this code in Access database (mdb) file,
with one table with the number for combinations, 2nd table with the
results and a form with the button than will run the code.
Thans Sotiris
Yeap, its possible, what you need is to transform the arrays into mdb files.
That's a questin that has already been asked here: http://www.thescripts.com/forum/thread553126.html so i think that might be of help.
Just transform the data base into an array, use the code i gave you, and create the answer array, then transform it into an mdb... I think there should be other ways, but this one could be of help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: tom |
last post by:
Hi,
How do I get the serial number of the harddisk in .NET?
I want this to be the same number even if the user has
reformatted, so I do not want the volume serial number.
Thanx,
t
|
by: King |
last post by:
Hi
I have following MS Acess query
Here is the query
ID Name Prgm ID Client ID Date Start Time End
Time Minutes
C4 Trisha TIP DEK0703 7 /7 /2006...
|
by: jmcgill |
last post by:
Hello.
Is there a method for computing the number of digits, in a given numeric
base, of N factorial, without actually computing the factorial?
For example, 8! has 5 digits in base 10; 10! has...
|
by: MLH |
last post by:
If 3 things can be in one of 2 states,
the number of possible combinations
is equal to 2^3.
But if I have 3 things, 2 of which can
be in 2 states and the other in 3 states,
what's the simplest...
|
by: alex28011969 |
last post by:
hi there,
i'm a newby in the world of XML but can somebody tell me how to create a tooltip in a XML document that contains a combination of a name & number?
i use a combination with Flash and...
|
by: barbk |
last post by:
Hey all,
In DB2 v9 is it possible to have an auto generated number field within a primary key that is a combination of multiple fields? For example
resv locn sale_no
1234 789...
|
by: csfong33 |
last post by:
Hi,
I have arrays below:
arr1 = { a, b, c}
arr2 = {1, 2, 3}
arr3 = {x, y, z}
I want to get a combination of these array, as below
arr_result = { "a1x", "a1y", "a1z", "a2x", "a2y", "a2z",...
|
by: Bails |
last post by:
Hi all I have a theory for a lotto system and need help on how to code
it.
I want to create 1 massive database with EVERY combination of numbers
possible in a given lotto system, then remove all...
|
by: theCancerus |
last post by:
Hi All,
I am not sure if this is the right place to ask this question but i am
very sure you may have faced this problem, i have already found some
post related to this but not the answer i am...
|
by: jinalpatel |
last post by:
I am dealing with 3 tables. Here is a brief meta data
see the attachment for the relationship
Conditions:
1)One GrantIndex can have multiple Deliverables
2)one Deliverable is made from...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |