I have a code under one button that copies the record and pastes it so that a new date can be used with the old values:
Private Sub chkOldValues_Click()
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdPasteAppend
Me.Days.Value = Me.txtDate.Value
[Forms]![frmGenSum]![UserID].Enabled = False
Me.chkOldValues.Value = False
End Sub
I also have a code that checks the date and userID to ensure that the same date (with the specified userID) have not been used before:
If chkOldValues.Value = True Then
Exit Sub
End If
Dim rs As Object
Set rs = CurrentDb.OpenRecordset("tblDailyReport")
If rs.EOF And rs.BOF Then
'Do nothing
End If
Do While Not rs.EOF
If rs!Days = [Forms]![frmGenSum].Days And rs!UserID = [Forms]![frmGenSum].UserID Then
MsgBox "This User ID has already used this date. Use the Previous Dates box to go to a date."
Exit Do
End If
Loop
Set rs = Nothing
End Sub
However, if I have both codes in the form, then only the copy record piece works. If I try to check a date, the database hangs. At the moment, only one or the other will work.
Any ideas on what is happening and how to fix it? I am not great at RecordSets, I happened across this code and modified it for my own use, but now it just won't play well with the other code! Thanks for all the help.