Hi All
I have the macro below for Access however after a new month is added, the screen just go back to the first month record instead of staying in the last record. I have used DoCmd.GoToRecord , , acLast but it still doesn't work.
Please can anybody tell me what have I done wrong? Many thanks.
Private Sub nextMonth_Click()
Dim newRecordResponse As Integer
Dim recordNumber As Long
If DCount("[monthID]", Screen.ActiveForm.RecordSource) = Screen.ActiveForm.CurrentRecord Then
newRecordResponse = MsgBox("This is the last record. " & _
"Do you want to create a new reporting month for " & _
vbCrLf & DateSerial(Year(Screen.ActiveForm.monthID), Month(Screen.ActiveForm.monthID) + 2, 0) & _
"?", vbYesNo)
If newRecordResponse = vbYes Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "q_appendStrategicProjects"
DoCmd.OpenQuery "q_appendStrategicProjectFinance"
DoCmd.SetWarnings False
Screen.ActiveForm.Requery
DoCmd.GoToRecord , , acLast
Else
End If
Else
DoCmd.GoToRecord , , acNext
End If
End Sub
I have the macro below for Access however after a new month is added, the screen just go back to the first month record instead of staying in the last record. I have used DoCmd.GoToRecord , , acLast but it still doesn't work.
Please can anybody tell me what have I done wrong? Many thanks.
Private Sub nextMonth_Click()
Dim newRecordResponse As Integer
Dim recordNumber As Long
If DCount("[monthID]", Screen.ActiveForm.RecordSource) = Screen.ActiveForm.CurrentRecord Then
newRecordResponse = MsgBox("This is the last record. " & _
"Do you want to create a new reporting month for " & _
vbCrLf & DateSerial(Year(Screen.ActiveForm.monthID), Month(Screen.ActiveForm.monthID) + 2, 0) & _
"?", vbYesNo)
If newRecordResponse = vbYes Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "q_appendStrategicProjects"
DoCmd.OpenQuery "q_appendStrategicProjectFinance"
DoCmd.SetWarnings False
Screen.ActiveForm.Requery
DoCmd.GoToRecord , , acLast
Else
End If
Else
DoCmd.GoToRecord , , acNext
End If
End Sub