473,473 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"Multiplication Table" type issue in ACCESS

33 New Member
Hi,
I have an issue very similar to the chart we used back in the stone ages to learn our multiplication facts. You remember, 1 - 10 as row headers, 1 - 10 as column headers and where the row and column intersect, the result of multiplying the column header by the row header.

For my data, if I did this in Excel, I'd have 170 columns and 170 rows but I'm not sure that's the best way. I'm assuming that I need 3 columns (column, row and result) and 28,900 rows (170*170). Is that the "correct" method?

Thanks,
Shawn
Nov 24 '15 #1
3 1142
zmbd
5,501 Recognized Expert Moderator Expert
You mention Excel; however, this is the VBA/Access forum. The solution I am showing here could be modified for Excel and a pivot table; however, I would think the simple cell formulas would work :)

ANYWAY.... for Access... CrossTab Query comes to the rescue:


For a 10 x 10 using 1 table with the records 1, 2, 3,... 9
Save the table as [Multipliers] with field named [PK] as numeric long
You can of course do this with two tables; however, why if the same values would be used.

Open a new query in design view.
Close the show table dialog box... this isn't easily done from the GUI Query editor
Right click in the table field and switch to SQLView

Cut and paste the following:

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM [T1]![PK]*[T2]![PK] 
  2.     AS Product
  3. SELECT [T1]![PK]
  4. FROM [Multipliers]
  5.        AS T1
  6.    , [Multipliers]
  7.        AS T2
  8. GROUP BY [T1]![PK]
  9. PIVOT [T2]![PK]
This will give you your 10*10 multiplication table.

I would think that something similar should work for your situation.
Nov 24 '15 #2
Shawn29316
33 New Member
zmbd,

Reading back through my post, it's probably only clear to me what I "MEANT" to say. - Sorry!
What I'm trying to figure out is how to create the table to hold the relationship between the data elements. I used the multiplication table as a visual but I'm really trying to figure out how to best design the table. Should the table look like the output from the query you wrote above or should it be 3 columns (element1, element2 and relationship)?
Thanks,
Shawn
Nov 24 '15 #3
zmbd
5,501 Recognized Expert Moderator Expert
Perfectly alright... it took me a few tries to get the right "question asking" skill down and I still occasionally get a poke-n-the-ribs when asking my own questions for pertinent information. :-D

I think you are still looking at a crosstab query (CTQ); however, it's difficult to tell from your description.

The other option as a Many:Many (M:M) relationship table.
IN all of the following, PK = Primary Key, FK = Foreign Key

+ tblA
[tblA]![PK] - numeric(long)
other fields as needed.

+ tblB
[tblB]![PK] - numeric(long)
other fields as needed.

>>> Something to note...
If you place [tblA] and [tblB] in a query without any relationships, place the [PK] in the show table grid, then you would get every possible combination of
([tblA]![PK],[tblB]![PK])
Called the cartesian product of the tables... this is the trick I used in the 10x10 SQL above, I just grouped out the duplicated entries.... This may be all you need?

if not then the M:M relationship table

+ tblAtoB
[tblAtoB]![PK]
[tblAtoB]![FK_tblA] - force no null
[tblAtoB]![FK_tblB] - force no null
Compound Index on [tblAtoB]![FK_tblA]:[tblAtoB]![FK_tblB]
Force unique value on compound key

Yes, one can use the compound key as a primary key, I; however, prefer not to do so for many reasons - primarily dealing with VBA coding.

From there is should be a simple matter to create the CTQ

Then there is the self join table, for example, a table with employees and managers

tblE
[tblE]![PK]
[tblE]![IK_Manager]
other fields as needed

In the table relationships:
[tblE]![PK] :1:M: [tblE]![IK_Manager]

An example is given here:
Having one field that will need multiple sub fields-Post#9
Now this shows a document management; however, the self join is quite common for other reasons.

Personally, I've never created a crosstab query directly from a table like this; however, I am sure that Rabbit, NeoPa, or one of the other experts has done so... seems like something one would do?!
Nov 24 '15 #4

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

Similar topics

1
by: Bue Krogh Vedel-Larsen | last post by:
I'm extending my C++ app by embedding Python 2.4.1 in it. The app is multithreaded and split into several DLL's. The main EXE calls Py_Initialize and Py_Finalize and each DLL gets a seperate...
0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has...
2
by: JT | last post by:
I have a compiler error when using a non-dependent type declared in a template, if I use the type in function definitions. I think it is a parsing issues related to confusion with a typename. ...
3
by: James Woo via SQLMonster.com | last post by:
Hi All I am getting an access denied message when I launch the Virtual Server administration screen, however I can connect through the Virtual Machine remote connectivity without any problems....
4
by: RichB | last post by:
Hello, The .NET application I have just installed at a client web site is throwing a strange error. At first the applications works without any problems, but after 10 mins or so Access denied...
3
by: NuB | last post by:
I have a C# program that is reading text files and uploading the data into SQL. The issue I'm noticing is that if i have money such as 1253.22 in the file, is loading in the table as 1253.22 but...
1
by: vinesh | last post by:
Hi I'm trying to access the content type of an open file through dotnet . But the content type id displayed wrongly when the file is open in my disc. the ontent type is displayed as...
3
by: Wayne | last post by:
I downloaded the Office 2007 Beta today and have been clicking around Access and the other Office Apps. They all have clear type switched on despite the fact that I have it turned off in Windows. ...
3
by: Big Daddy | last post by:
I have added a resource file to my project called "DemoSite1Resources.resx". I have seen an example in VB where you could have type-safe access to the resources in your code like this: btn.Text...
19
by: lost1 | last post by:
Can someone point me in the right direction on how to get the triangle type to display. Below is a triangle class that is tested by another completely separate class. The main method of the test...
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
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
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...
0
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
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.