Hello All! This is my first form post and I'll admit that i've been lurking and learned nearly everything I know about access VBA from this site.
I am setting up a database that keeps track of parts, breakdowns, and maintenance for machines at our factory (CNH-Saskatoon).
We use 4 triangles filled into a square to visually represent activities/part/month. I originally created a seperate table to represent a filename to change a picture to. Data was added to this via SQL statements and was only joined via partID. I would like to create a query that generates this data so that when information is changed or deleted it updates the triangles appropriatly.
When I use the following SQL statement it creates a new line for each months expression. Ideally I just want 1 line for each part containing all the data needed. I was thinking of checking if the next line was the same and then updating and deleting the rows accordingly. But.... This seems like the wrong approach; any other ideas??
SELECT tblGroups.AssetID, tblGroups.GroupID, tblSubs.SubID, tblParts.PartID, tblParts.PartName, tblParts.PartClass, IIf(Month([PMdueDate])=1,1,0) & IIf(Month([EWODate])=1,1,0) & IIf(Month([PMcompDate])=1,1,0) & IIf(Month([NoteDate])=1,1,0) AS January, IIf(Month([PMdueDate])=2,1,0) & IIf(Month([EWODate])=2,1,0) & IIf(Month([PMcompDate])=2,1,0) & IIf(Month([NoteDate])=2,1,0) AS February, IIf(Month([PMdueDate])=3,1,0) & IIf(Month([EWODate])=3,1,0) & IIf(Month([PMcompDate])=3,1,0) & IIf(Month([NoteDate])=3,1,0) AS March, IIf(Month([PMdueDate])=4,1,0) & IIf(Month([EWODate])=4,1,0) & IIf(Month([PMcompDate])=4,1,0) & IIf(Month([NoteDate])=4,1,0) AS April, IIf(Month([PMdueDate])=5,1,0) & IIf(Month([EWODate])=5,1,0) & IIf(Month([PMcompDate])=5,1,0) & IIf(Month([NoteDate])=5,1,0) AS May, IIf(Month([PMdueDate])=6,1,0) & IIf(Month([EWODate])=6,1,0) & IIf(Month([PMcompDate])=6,1,0) & IIf(Month([NoteDate])=6,1,0) AS June, IIf(Month([PMdueDate])=7,1,0) & IIf(Month([EWODate])=7,1,0) & IIf(Month([PMcompDate])=7,1,0) & IIf(Month([NoteDate])=7,1,0) AS July, IIf(Month([PMdueDate])=8,1,0) & IIf(Month([EWODate])=8,1,0) & IIf(Month([PMcompDate])=8,1,0) & IIf(Month([NoteDate])=8,1,0) AS August, IIf(Month([PMdueDate])=9,1,0) & IIf(Month([EWODate])=9,1,0) & IIf(Month([PMcompDate])=9,1,0) & IIf(Month([NoteDate])=9,1,0) AS September, IIf(Month([PMdueDate])=10,1,0) & IIf(Month([EWODate])=10,1,0) & IIf(Month([PMcompDate])=10,1,0) & IIf(Month([NoteDate])=10,1,0) AS October, IIf(Month([PMdueDate])=11,1,0) & IIf(Month([EWODate])=11,1,0) & IIf(Month([PMcompDate])=11,1,0) & IIf(Month([NoteDate])=11,1,0) AS November, IIf(Month([PMdueDate])=12,1,0) & IIf(Month([EWODate])=12,1,0) & IIf(Month([PMcompDate])=12,1,0) & IIf(Month([NoteDate])=12,1,0) AS December
FROM (tblGroups INNER JOIN tblSubs ON tblGroups.GroupID = tblSubs.GroupID) INNER JOIN ((tblSMPs LEFT JOIN tblPMs ON tblSMPs.SMPID = tblPMs.SMPID) RIGHT JOIN (((tblParts LEFT JOIN tblEWOs ON tblParts.PartID = tblEWOs.PartID) LEFT JOIN tblNotes ON tblParts.PartID = tblNotes.PartID) LEFT JOIN tblSMPparts ON tblParts.PartID = tblSMPparts.PartID) ON tblSMPs.SMPID = tblSMPparts.SMPID) ON tblSubs.SubID = tblParts.SubID
WHERE (((tblGroups.AssetID)=[TempVars]![tvAssetID]) AND ((tblGroups.GroupID) Like [TempVars]![tvGroupID]) AND ((tblSubs.SubID) Like [TempVars]![tvSubID]));
Outputs as:
PartName January February March April
Part1 0000 0100 0000 0000
Part1 0000 0000 0100 0000
Part1 0000 0000 0000 0100
(When there are multiple dates for same part)
What I want:
PartName January February March April
Part1 0000 0100 0100 0100
Thanks so much in advance!
I am setting up a database that keeps track of parts, breakdowns, and maintenance for machines at our factory (CNH-Saskatoon).
We use 4 triangles filled into a square to visually represent activities/part/month. I originally created a seperate table to represent a filename to change a picture to. Data was added to this via SQL statements and was only joined via partID. I would like to create a query that generates this data so that when information is changed or deleted it updates the triangles appropriatly.
When I use the following SQL statement it creates a new line for each months expression. Ideally I just want 1 line for each part containing all the data needed. I was thinking of checking if the next line was the same and then updating and deleting the rows accordingly. But.... This seems like the wrong approach; any other ideas??
SELECT tblGroups.AssetID, tblGroups.GroupID, tblSubs.SubID, tblParts.PartID, tblParts.PartName, tblParts.PartClass, IIf(Month([PMdueDate])=1,1,0) & IIf(Month([EWODate])=1,1,0) & IIf(Month([PMcompDate])=1,1,0) & IIf(Month([NoteDate])=1,1,0) AS January, IIf(Month([PMdueDate])=2,1,0) & IIf(Month([EWODate])=2,1,0) & IIf(Month([PMcompDate])=2,1,0) & IIf(Month([NoteDate])=2,1,0) AS February, IIf(Month([PMdueDate])=3,1,0) & IIf(Month([EWODate])=3,1,0) & IIf(Month([PMcompDate])=3,1,0) & IIf(Month([NoteDate])=3,1,0) AS March, IIf(Month([PMdueDate])=4,1,0) & IIf(Month([EWODate])=4,1,0) & IIf(Month([PMcompDate])=4,1,0) & IIf(Month([NoteDate])=4,1,0) AS April, IIf(Month([PMdueDate])=5,1,0) & IIf(Month([EWODate])=5,1,0) & IIf(Month([PMcompDate])=5,1,0) & IIf(Month([NoteDate])=5,1,0) AS May, IIf(Month([PMdueDate])=6,1,0) & IIf(Month([EWODate])=6,1,0) & IIf(Month([PMcompDate])=6,1,0) & IIf(Month([NoteDate])=6,1,0) AS June, IIf(Month([PMdueDate])=7,1,0) & IIf(Month([EWODate])=7,1,0) & IIf(Month([PMcompDate])=7,1,0) & IIf(Month([NoteDate])=7,1,0) AS July, IIf(Month([PMdueDate])=8,1,0) & IIf(Month([EWODate])=8,1,0) & IIf(Month([PMcompDate])=8,1,0) & IIf(Month([NoteDate])=8,1,0) AS August, IIf(Month([PMdueDate])=9,1,0) & IIf(Month([EWODate])=9,1,0) & IIf(Month([PMcompDate])=9,1,0) & IIf(Month([NoteDate])=9,1,0) AS September, IIf(Month([PMdueDate])=10,1,0) & IIf(Month([EWODate])=10,1,0) & IIf(Month([PMcompDate])=10,1,0) & IIf(Month([NoteDate])=10,1,0) AS October, IIf(Month([PMdueDate])=11,1,0) & IIf(Month([EWODate])=11,1,0) & IIf(Month([PMcompDate])=11,1,0) & IIf(Month([NoteDate])=11,1,0) AS November, IIf(Month([PMdueDate])=12,1,0) & IIf(Month([EWODate])=12,1,0) & IIf(Month([PMcompDate])=12,1,0) & IIf(Month([NoteDate])=12,1,0) AS December
FROM (tblGroups INNER JOIN tblSubs ON tblGroups.GroupID = tblSubs.GroupID) INNER JOIN ((tblSMPs LEFT JOIN tblPMs ON tblSMPs.SMPID = tblPMs.SMPID) RIGHT JOIN (((tblParts LEFT JOIN tblEWOs ON tblParts.PartID = tblEWOs.PartID) LEFT JOIN tblNotes ON tblParts.PartID = tblNotes.PartID) LEFT JOIN tblSMPparts ON tblParts.PartID = tblSMPparts.PartID) ON tblSMPs.SMPID = tblSMPparts.SMPID) ON tblSubs.SubID = tblParts.SubID
WHERE (((tblGroups.AssetID)=[TempVars]![tvAssetID]) AND ((tblGroups.GroupID) Like [TempVars]![tvGroupID]) AND ((tblSubs.SubID) Like [TempVars]![tvSubID]));
Outputs as:
PartName January February March April
Part1 0000 0100 0000 0000
Part1 0000 0000 0100 0000
Part1 0000 0000 0000 0100
(When there are multiple dates for same part)
What I want:
PartName January February March April
Part1 0000 0100 0100 0100
Thanks so much in advance!