G
Guest
I'm using Access 2003. I have a Projects form, and a Reports subform linked
by Project_ID and Grant_Type. The Reports table has fields [Project_ID],
[Grant_Type], [Year], [RptQ1], [RptQ2], [RptQ3] and [RptQ4]. At the
beginning of every year, I would like to have a query insert a new record for
each project in the Reports table - so on January 1st 2008 I want every
project to have an entry in the Reports table with that Project_ID,
Grant_Type and the year 2008. I've been playing with the following code:
Dim X AS Integer
Dim Y AS Integer
Dim FY AS Integer
X= CurrentProject.Connection.Execute “SELECT Min ([Project_ID]) FROM
TblReports;â€
Y= CurrentProject.Connection.Execute “SELECT Max ([Project_ID]) FROM
TblReports;â€
FY=InputBox (“What FY?â€)
For I as Integer = X to Y
CurrentProject.Connection.Execute “INSERT INTO TblReports
(Project_ID,Grant_Type,Year) SELECT " & I & ", Grant_Type," & FY & " FROM
TblProjects;"
Next I
But I want it to be able to skip a record if either the Project_ID does not
exist in the Projects table or if there is already a record for 2008 for that
Project_ID/Grant_Type in the Reports table.
by Project_ID and Grant_Type. The Reports table has fields [Project_ID],
[Grant_Type], [Year], [RptQ1], [RptQ2], [RptQ3] and [RptQ4]. At the
beginning of every year, I would like to have a query insert a new record for
each project in the Reports table - so on January 1st 2008 I want every
project to have an entry in the Reports table with that Project_ID,
Grant_Type and the year 2008. I've been playing with the following code:
Dim X AS Integer
Dim Y AS Integer
Dim FY AS Integer
X= CurrentProject.Connection.Execute “SELECT Min ([Project_ID]) FROM
TblReports;â€
Y= CurrentProject.Connection.Execute “SELECT Max ([Project_ID]) FROM
TblReports;â€
FY=InputBox (“What FY?â€)
For I as Integer = X to Y
CurrentProject.Connection.Execute “INSERT INTO TblReports
(Project_ID,Grant_Type,Year) SELECT " & I & ", Grant_Type," & FY & " FROM
TblProjects;"
Next I
But I want it to be able to skip a record if either the Project_ID does not
exist in the Projects table or if there is already a record for 2008 for that
Project_ID/Grant_Type in the Reports table.