I have a form that is used to run some reports and queries that update tables - I want the user to see the last month of data that has been entered into the table so they know if the last time it was updated (year to date data is appended to calcluate scores on a monthly basis)
I currently have this which does the same thing for two tables. The code is located in the after update event of the year field on my form - can I somehow condense this?
Thanks!!!!!
Dim strsql As String
Dim strsql1 As String
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
'updates the "MaxCPMonth" field with the max month field in tblSummaryCompletePaperwork
'using the year on the form
strsql = "SELECT Max(monthnumber) " & _
"FROM tblSummaryCompletePaperwork " & _
"Where Year = " & Me!year
Set rs = CurrentDb.OpenRecordset(strsql)
If Not rs.BOF And Not rs.EOF Then
Me.maxCPmonth = rs.Fields(0).Value
End If
'updates the "MaxMMMonth" field with the max month field in tblSummaryMemberMaintenance
'using the year on the form
strsql1 = "SELECT Max(monthnumber) " & _
"FROM tblSummaryMemberMaintenance " & _
"Where Year = " & Me!year
Set rs1 = CurrentDb.OpenRecordset(strsql1)
If Not rs.BOF And Not rs.EOF Then
Me.MaxMMMonth = rs.Fields(0).Value
End If
I currently have this which does the same thing for two tables. The code is located in the after update event of the year field on my form - can I somehow condense this?
Thanks!!!!!
Dim strsql As String
Dim strsql1 As String
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
'updates the "MaxCPMonth" field with the max month field in tblSummaryCompletePaperwork
'using the year on the form
strsql = "SELECT Max(monthnumber) " & _
"FROM tblSummaryCompletePaperwork " & _
"Where Year = " & Me!year
Set rs = CurrentDb.OpenRecordset(strsql)
If Not rs.BOF And Not rs.EOF Then
Me.maxCPmonth = rs.Fields(0).Value
End If
'updates the "MaxMMMonth" field with the max month field in tblSummaryMemberMaintenance
'using the year on the form
strsql1 = "SELECT Max(monthnumber) " & _
"FROM tblSummaryMemberMaintenance " & _
"Where Year = " & Me!year
Set rs1 = CurrentDb.OpenRecordset(strsql1)
If Not rs.BOF And Not rs.EOF Then
Me.MaxMMMonth = rs.Fields(0).Value
End If