Basshopper
Technical User
I have a query behind a subform for selecting parts. What kind of code with a command button would I use to put a check in Use part? field which is a check box on the subform, Parameters for a particular Customer ID, Assembly # and Quote #. I would like to run the code to do the check after I have pulled up the data into the form. The criteria is lowest Unit 1 per line # all line # must have a Check in the Use part? Hope I am explaining myself here. Here is my query
Code:
SELECT [t_BOM Part Cross].[Customer ID], [t_BOM Part Cross].[Assembly #], [t_BOM Part Cross].[quote=#], [t_BOM Part Cross].[Ascentron #], [t_BOM Part Cross].Rev, [t_BOM Part Cross].Ref, [t_BOM Part Cross].[Line #], [t_BOM Part Cross].[Customers #], [t_BOM Part Cross].Description, [t_BOM Part Cross].MFG, [t_BOM Part Cross].[U/M], [t_BOM Part Cross].[Qty Per], [t_BOM Part Cross].[Use Part?], [t_BOM Part Cross].[Alt MFG #], [t_BOM Part Cross].[Cust Cost], [t_BOM Part Cross].[Alt Unit 1], [t_BOM Part Cross].[Alt Unit 2], [t_BOM Part Cross].[Alt Unit 3], [t_BOM Part Cross].[Alt Unit 4], [t_BOM Part Cross].[Alt Unit 5], [t_BOM Part Cross].[Alt Unit 6], [t_BOM Part Cross].[Alt Unit 7], [t_BOM Part Cross].[Alt Unit 8], [t_BOM Part Cross].[Alt Unit 9], [t_BOM Part Cross].[Alt Unit 10], [t_BOM Part Cross].[Alt Unit 11], [t_BOM Part Cross].[Alt Unit 12], [t_BOM Part Cross].[MIN LT], [t_BOM Part Cross].[MAX LT], [t_BOM Part Cross].[Min Qty], [t_BOM Part Cross].[Alt Pkg Size], [t_BOM Part Cross].[Lot Charge], [t_BOM Part Cross].[Lot Qty], [t_BOM Part Cross].NRE, [t_BOM Part Cross].ETF, [t_BOM Part Cross].Tooling, [t_BOM Part Cross].[Other NRE], [t_BOM Part Cross].Vendor, [t_BOM Part Cross].Stock, [t_BOM Part Cross].Comments, [t_Quote Qty]![Qty 1]*[Qty Per]*[Alt Unit 1] AS [Unit 1 Ext], IIf([Min Qty]=0,0,IIf([Qty 1]*[Qty Per]=0,0,IIf([Qty 1]*[Qty Per]<[Min Qty],(([Min Qty]-[Qty 1]*[Qty Per])*[Alt Unit 1]),IIf(([Qty 1]*[Qty Per]/[Alt Pkg Size])=Int([Qty 1]*[Qty Per]/[Alt Pkg Size]),0,[Alt Pkg Size]-(((([Qty 1]*[Qty Per]/[Alt Pkg Size])-Int([Qty 1]*[Qty Per]/[Alt Pkg Size]))*[Alt Pkg Size])))*[Alt Unit 1]))) AS [XCS 1 Ext], [t_Quote Qty]![Qty 2]*[Qty Per]*[Alt Unit 2] AS [Unit 2 Ext], IIf([Min Qty]=0,0,IIf([Qty 2]*[Qty Per]=0,0,IIf([Qty 2]*[Qty Per]<[Min Qty],(([Min Qty]-[Qty 2]*[Qty Per])*[Alt Unit 2]),IIf(([Qty 2]*[Qty Per]/[Alt Pkg Size])=Int([Qty 2]*[Qty Per]/[Alt Pkg Size]),0,[Alt Pkg Size]-(((([Qty 2]*[Qty Per]/[Alt Pkg Size])-Int([Qty 2]*[Qty Per]/[Alt Pkg Size]))*[Alt Pkg Size])))*[Alt Unit 2]))) AS [XCS 2 Ext], [t_Quote Qty]![Qty 3]*[Qty Per]*[Alt Unit 3] AS [Unit 3 Ext], IIf([Min Qty]=0,0,IIf([Qty 3]*[Qty Per]=0,0,IIf([Qty 3]*[Qty Per]<[Min Qty],(([Min Qty]-[Qty 3]*[Qty Per])*[Alt Unit 3]),IIf(([Qty 3]*[Qty Per]/[Alt Pkg Size])=Int([Qty 3]*[Qty Per]/[Alt Pkg Size]),0,[Alt Pkg Size]-(((([Qty 3]*[Qty Per]/[Alt Pkg Size])-Int([Qty 3]*[Qty Per]/[Alt Pkg Size]))*[Alt Pkg Size])))*[Alt Unit 3]))) AS [XCS 3 Ext], [t_Quote Qty]![Qty 4]*[Qty Per]*[Alt Unit 4] AS [Unit 4 Ext], IIf([Min Qty]=0,0,IIf([Qty 4]*[Qty Per]=0,0,IIf([Qty 4]*[Qty Per]<[Min Qty],(([Min Qty]-[Qty 4]*[Qty Per])*[Alt Unit 4]),IIf(([Qty 4]*[Qty Per]/[Alt Pkg Size])=Int([Qty 4]*[Qty Per]/[Alt Pkg Size]),0,[Alt Pkg Size]-(((([Qty 4]*[Qty Per]/[Alt Pkg Size])-Int([Qty 4]*[Qty Per]/[Alt Pkg Size]))*[Alt Pkg Size])))*[Alt Unit 4]))) AS [XCS 4 Ext], [t_Quote Qty]![Qty 5]*[Qty Per]*[Alt Unit 5] AS [Unit 5 Ext], IIf([Min Qty]=0,0,IIf([Qty 5]*[Qty Per]=0,0,IIf([Qty 5]*[Qty Per]<[Min Qty],(([Min Qty]-[Qty 5]*[Qty Per])*[Alt Unit 5]),IIf(([Qty 5]*[Qty Per]/[Alt Pkg Size])=Int([Qty 5]*[Qty Per]/[Alt Pkg Size]),0,[Alt Pkg Size]-(((([Qty 5]*[Qty Per]/[Alt Pkg Size])-Int([Qty 5]*[Qty Per]/[Alt Pkg Size]))*[Alt Pkg Size])))*[Alt Unit 5]))) AS [XCS 5 Ext], [t_Quote Qty]![Qty 6]*[Qty Per]*[Alt Unit 6] AS [Unit 6 Ext], IIf([Min Qty]=0,0,IIf([Qty 6]*[Qty Per]=0,0,IIf([Qty 6]*[Qty Per]<[Min Qty],(([Min Qty]-[Qty 6]*[Qty Per])*[Alt Unit 6]),IIf(([Qty 6]*[Qty Per]/[Alt Pkg Size])=Int([Qty 6]*[Qty Per]/[Alt Pkg Size]),0,[Alt Pkg Size]-(((([Qty 6]*[Qty Per]/[Alt Pkg Size])-Int([Qty 6]*[Qty Per]/[Alt Pkg Size]))*[Alt Pkg Size])))*[Alt Unit 6]))) AS [XCS 6 Ext]
FROM [t_Quote Qty] LEFT JOIN [t_BOM Part Cross] ON [t_Quote Qty].[quote=#] = [t_BOM Part Cross].[quote=#]
ORDER BY [t_BOM Part Cross].[Customer ID], [t_BOM Part Cross].[Assembly #], [t_BOM Part Cross].[quote=#], [t_BOM Part Cross].[Line #];