Populate sub form with data from a table/query

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I have a form with a sub form, on the main form I want the user to select a machine number and then when they have selected it I want to populate the required data into the sub form.

In the sub form I have a field called "Seal" and another called "Quantity" what I require is to get the results from either a query or table and list all the seals & quantities for that machine.

I have a table called "Machine" which has all the machine numbers and also fields called "Seal1", "Seal1Qty","Seal2, "Seal2Qty" all the way to Seal 10.

I do not know how the best way to get this data into the sub form, any help would be great.

Regards,
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Sounds like you need a lookup. I recommend vlookup or index/match. This would basically look for the machine number inputted and return values from the Machine table. For an exact formula, please post a sample.
Alex
 
Upvote 0
Hi,

In that "Machine" table there are fields for Machine Number, Seal1.Seal1Qty,Seal2,Seal2Qty etc up to seal 10.
In the sub form there is a fiels called Seal, Quantity

What I need is when the user selects the machine number that the sub form looks at all the seal fields for that machine and if there is a seal then insert the seal and the quantity into the sub form and do this for all 10 seals.

Example

Machine table

Machine Seal1 Seal1Qty Seal2 Seal2qty
1 1" 2 2" RJT 6

Sub form

Seal Quantity
1" 2
2" RJT 6
 
Upvote 0
<title>Excel Jeanie HTML</title>If this is the Machine table in sheet1:

*ABCDEFGHIJKLMNOPQRSTU
1MachineSeal1Seal1QtySeal2Seal2QtySeal3Seal3QtySeal4Seal4QtySeal5Seal5QtySeal6Seal6QtySeal7Seal7QtySeal8Seal8QtySeal9Seal9QtySeal10Seal10Qty
211"22"RJT63"a4"b5"c6"d7"e8"f9"g10"h

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

And the sub form in sheet2:

*ABC
1MachineSealQuantity
211"2
3*2"RJT6
4*3"a
5*4"b
6*5"c
7*6"d
8*7"e
9*8"f
10*9"g
11*10"h

<tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B2=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,2)
C2=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,3)
B3=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,4)
C3=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,5)
B4=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,6)
C4=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,7)
B5=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,8)
C5=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,9)
B6=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,10)
C6=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,11)
B7=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,12)
C7=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,13)
B8=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,14)
C8=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,15)
B9=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,16)
C9=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,17)
B10=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,18)
C10=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,19)
B11=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,20)
C11=VLOOKUP(Sheet2!$A$2,Sheet1!A:U,21)

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

Alex
<!-- ######### End Created Html Code To Copy ########## -->
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,415
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top