M
Maresdd
I get a Run-time error 3144 with the following update statement. Could
somebody please help me with where I'm going wrong.
Private Sub UpdShifts_Click()
Dim strSQL As String
Dim strSQL2 As String
Dim Usern As String
Dim strReason As String
strReason = DLookup("[Reason]", "tblcnbreakdetails", "[ServiceNo] =
Forms!frmcnbreak!ServiceNumber AND [Breakdate] =
Forms!frmcnbreak!frmcnbreaksubform!break")
Usern = fOSUserName()
DoCmd.SetWarnings False
strSQL = "UPDATE tblContracts INNER JOIN tblService_Date_and_Times ON
tblContracts.[Service No] = tblService_Date_and_Times.Service_Plan_ID SET
tblService_Date_and_Times.Hold = True, tblService_Date_and_Times.Notes = " &
strReason & " & "" "" & fOSUserName() & "" "" & Format(Now(),""Short Date"")"
& vbCrLf & _
"WHERE
(((tblService_Date_and_Times.ServDate)>=[Forms]![frmCNbreak]![frmCNbreaksubform]![Break]
And
(tblService_Date_and_Times.ServDate)<=[Forms]![frmcnbreak]![frmcnbreaksubform]![Return])
AND
((tblService_Date_and_Times.Service_Plan_ID)=[Forms]![frmCNbreak]![ServiceNumber]));"
strSQL2 = "UPDATE tblContracts INNER JOIN tblService_Date_and_Times ON
tblContracts.[Service No] = tblService_Date_and_Times.Service_Plan_ID SET
tblService_Date_and_Times.Hold = True, tblService_Date_and_Times.Notes =" &
strReason & " & "" "" & fOSUserName() & "" "" & Format(Now(),""Short Date"")"
& vbCrLf & _
"WHERE
(((tblService_Date_and_Times.ServDate)>=[Forms]![frmCNbreak]![frmcnbreaksubform]![Break])
AND
((tblService_Date_and_Times.Service_Plan_ID)=[Forms]![frmCNbreak]![ServiceNumber]));"
If IsNull(Forms!frmcnbreak!frmcnbreaksubform!Return) Then
DoCmd.RunSQL strSQL2
ElseIf Not IsNull(Forms!frmcnbreak!frmcnbreaksubform!Return) Then
DoCmd.RunSQL strSQL
End If
DoCmd.SetWarnings True
End Sub
somebody please help me with where I'm going wrong.
Private Sub UpdShifts_Click()
Dim strSQL As String
Dim strSQL2 As String
Dim Usern As String
Dim strReason As String
strReason = DLookup("[Reason]", "tblcnbreakdetails", "[ServiceNo] =
Forms!frmcnbreak!ServiceNumber AND [Breakdate] =
Forms!frmcnbreak!frmcnbreaksubform!break")
Usern = fOSUserName()
DoCmd.SetWarnings False
strSQL = "UPDATE tblContracts INNER JOIN tblService_Date_and_Times ON
tblContracts.[Service No] = tblService_Date_and_Times.Service_Plan_ID SET
tblService_Date_and_Times.Hold = True, tblService_Date_and_Times.Notes = " &
strReason & " & "" "" & fOSUserName() & "" "" & Format(Now(),""Short Date"")"
& vbCrLf & _
"WHERE
(((tblService_Date_and_Times.ServDate)>=[Forms]![frmCNbreak]![frmCNbreaksubform]![Break]
And
(tblService_Date_and_Times.ServDate)<=[Forms]![frmcnbreak]![frmcnbreaksubform]![Return])
AND
((tblService_Date_and_Times.Service_Plan_ID)=[Forms]![frmCNbreak]![ServiceNumber]));"
strSQL2 = "UPDATE tblContracts INNER JOIN tblService_Date_and_Times ON
tblContracts.[Service No] = tblService_Date_and_Times.Service_Plan_ID SET
tblService_Date_and_Times.Hold = True, tblService_Date_and_Times.Notes =" &
strReason & " & "" "" & fOSUserName() & "" "" & Format(Now(),""Short Date"")"
& vbCrLf & _
"WHERE
(((tblService_Date_and_Times.ServDate)>=[Forms]![frmCNbreak]![frmcnbreaksubform]![Break])
AND
((tblService_Date_and_Times.Service_Plan_ID)=[Forms]![frmCNbreak]![ServiceNumber]));"
If IsNull(Forms!frmcnbreak!frmcnbreaksubform!Return) Then
DoCmd.RunSQL strSQL2
ElseIf Not IsNull(Forms!frmcnbreak!frmcnbreaksubform!Return) Then
DoCmd.RunSQL strSQL
End If
DoCmd.SetWarnings True
End Sub