insert a template table into a sub sub fm

BBBryan

Registered User.
Local time
Yesterday, 22:14
Joined
Nov 13, 2010
Messages
122
Hi,
If someone could Help me
I would like to insert this template table [Itp Piping Template tbl]
Into a sub sub form [ITP WorkOrder fm]![ItpDescriptionInfo fm]![ITP Piping fm]
from a button on this sub sub form.
In the [ITP Piping fm] I want to add the 30 rows of records to these fields
Item, Description, Sub Description, InfoDescription, 2ndInfoDescription, CodeSpec. which are the same names in the template.

The way I do it now is go to the template [Itp Piping Template tbl] copy it and then go back to the Form [ITP WorkOrder fm]![ItpDescriptionInfo fm]![ITP Piping fm] and paste it in which works.
I want it more efficient.

I have this now from a button on the sub sub form on click. It does paste the template table into the Piping table but it is not linked to anything.

INSERT INTO [Itp Piping tbl] ([Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription],[CodeSpec] )
SELECT [Itp Piping Template tbl].Item, [Itp Piping Template tbl].Description, [Itp Piping Template tbl].[Sub Description], [Itp Piping Template tbl].InfoDescription, [Itp Piping Template tbl].[2ndInfoDescription],[Itp Piping Template tbl].CodeSpec
FROM [Itp Piping Template tbl];
End Sub

Thanks BBryan
 
Hi Pat, Thanks
After I re-read what I posted yeh not clear sorry.


After I click on the button the template table appends to the table ([ITP Piping tbl]) The ID numbers for the ITP WorkOrder tbl and ItpDescriptionInfo tbl do not populate into the appended ITP Piping tbl. Like they would if you add somthing in the form.

The tables are nested in the form.
ItpID(Piping) from [ITP Piping tbl] related/linked to WoNoID
WoNoID from [ItpDescriptionInfo tbl] related/linked to WorkOrderID
WorkOrderID from [ITP WorkOrder tbl]

Somehow in the code I need to add the ID numbers from the other tables when it appends and I don't know how to do that.

BBryan
 
Hi Pat thanks

In your example I see - Forms!yourform!ToPK as ToPK does that mean I have make a relationship from my template Table [Itp Piping Template tbl] to the table [Itp Piping tbl] I want to insert into and use that ID.
Right now I have the template not related to anything.the Key is called ItpTempID(Piping) from [Itp Piping Template tbl]

These ID's are all PK's in there own table.
ItpID(Piping) from [ITP Piping tbl] related/linked to WoNoID
WoNoID from [ItpDescriptionInfo tbl] related/linked to WorkOrderID WorkOrderID from [ITP WorkOrder tbl]

Thanks BBryan
 
Hi Pat,
I have this now in a query
INSERT INTO [Itp Piping tbl] ([Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription],[CodeSpec] , [WorkOrderID])
SELECT [Itp Piping Template tbl].Item, [Itp Piping Template tbl].Description, [Itp Piping Template tbl].[Sub Description], [Itp Piping Template tbl].InfoDescription, [Itp Piping Template tbl].[2ndInfoDescription],[Itp Piping Template tbl].CodeSpec, Forms![ITP WorkOrder fm]!To [WorkOrderID] as To [WorkOrderID]
FROM [Itp Piping Template tbl] WHERE ItpID(Piping) = [ITP WorkOrder fm]![ItpDescriptionInfo fm]![ITP Piping fm] From WorkOrderID;
End Sub
But it is givin an error on the insert TO
Does it look right now.

BBryan
 
Thanks
Sorry But I might not be getting it.
when you say The PK of the "from" parent and the PK of the "to" parent.
Do you mean
INSERT INTO [Itp Piping tbl] ([Item], [Description], [Sub Description], [InfoDescription], [2ndInfoDescription],[CodeSpec] , [WorkOrderID])
This should be the PK [WorkOrderID] from the "TO"
And
Forms![ITP WorkOrder fm]![ItpDescriptionInfo fm]![ITP Piping fm]! To [WorkOrderID] as To [WorkOrderID]
The whole FormName with the "TO" PK and again the "TO" PK
And
FROM [Itp Piping Template tbl] WHERE [ItpID(Piping)] = [ITP WorkOrder fm]![ItpDescriptionInfo fm]![ITP Piping fm] From [WorkOrderID];
The PK "FROM"


I know what you mean to put no embedded spaces or special characters. I will need to change that on a day off.

Thanks BBryan And I appreciateyour help
 

Users who are viewing this thread

Back
Top Bottom