Private Sub cmdgo2_Click()
Dim userID As Long
Dim strQuery As String
userID = DLookup("EmployeeID", "qryEmployeeNames", "EmployeeName='" & Me.txtwinusername & "'")
If DCount("*", "tblactivities", "EmployeeID = " & userID & " AND dte = Date()") = 0 Then
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID
Forms!entertodaysrecords!ctrActivity.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew
Else
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID
With Forms!entertodaysrecords!ctrActivity
.SetFocus
.Form.Recordset.FindFirst "ActivitiesID = " & DMax("ActivitiesID", "tblactivities", "EmployeeID = " & userID)
End With
End If
If DCount("*", "tblafternoon", "EmployeeID = " & userID & " AND dte = Date()") = 0 Then
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID
Forms!entertodaysrecords!frmctrActivity2.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew
Else
DoCmd.OpenForm "entertodaysrecords", acNormal, , "EmployeeID = " & userID
With Forms!entertodaysrecords!frmctrActivity2
.SetFocus
.Form.Recordset.FindFirst "ActivitiesID = " & DMax("ActivitiesID", "tblafternoon", "EmployeeID = " & userID)
End With
End If
Exit_cmdGo2_Click:
Exit Sub
Err_cmdGo2_Click:
MsgBox Err.Description
Resume Exit_cmdGo2_Click
End Sub