J
Joshua
Hello,
I am getting the error
"Run-time error '3075':
Syntax error (missing operator) in query expression 'Joshua McLemore'.
The 'Joshua McLemore' is the field lngEmpID I'm trying to insert below.
The error on debug then highlights the first db.Execute strSQL,
dbFailOnError in the code below:
Private Sub cmdBuildSchedule_Click()
Dim datThis As Date
Dim lngEvtID As String
Dim lngLocID As String
Dim lngPartsID As String
Dim lngEmpID As String
Dim lngPosID As String
Dim lngDepId As String
Dim lngTypID As String
Dim varNotes As Variant
Dim strSQL As String
Dim db As DAO.Database
Dim intDOW As Integer 'day of week
Dim intDIM As Integer 'Day in month
If Me.grpRepeats = 2 Then
If Not CheckDates() Then
Exit Sub
End If
End If
If Not CheckTimes() Then
Exit Sub
End If
If IsNull(Me.cboActID) Then
MsgBox "You must select an Event Name.", vbOKOnly + vbInformation,
"Enter Event Name"
Me.cboActID.SetFocus
Me.cboActID.Dropdown
Exit Sub
End If
If IsNull(Me.cboLocID) Then
MsgBox "You must select a Location.", vbOKOnly + vbInformation,
"Enter Location"
Me.cboLocID.SetFocus
Me.cboLocID.Dropdown
Exit Sub
End If
varNotes = Me.txtNotes
lngLocID = Me.cboLocID
lngEvtID = Me.cboActID
lngPartsID = Me.cboPartID
lngEmpID = Me.cboEmpID
lngPosID = Me.cboPosID
lngDepId = Me.cboDepID
lngTypID = Me.cboTypID
Set db = CurrentDb
If Me.grpRepeats = 2 Then 'need to loop through dates
For datThis = Me.txtStartDate To Me.txtEndDate
intDIM = GetDIM(datThis)
intDOW = Weekday(datThis)
If Me("chkDay" & intDIM & intDOW) = True Or _
Me("chkDay0" & intDOW) = True Then
strSQL = "INSERT INTO tblTempSchedDates (" & _
"tscDate, tscEvtID, tscPartsID, tscEmpID, tscLocID,
tscPosID, tscDepID, tscTypID, " & _
"tscStartTime, tscEndTime, tscCallTime, tscOutTime,
tscNotes ) " & _
"Values(#" & datThis & "#," & lngEvtID & "," &
lngPartsID & "," & lngEmpID & "," & lngLocID & "," & lngPosID & "," &
lngDepId & ", " & _
lngTypID & ", #" & Me.txtStartTime & "#, #" & _
Me.txtEndTime & "#, #" & _
Me.txtCallTime & "#, #" & _
Me.txtOutTime & "#," & _
IIf(IsNull(varNotes), "Null", """" & varNotes & """") &
")"
db.Execute strSQL, dbFailOnError
End If
Next
Else 'dates are there, just add the title, notes, times, location,
Activity
strSQL = "Update tblTempSchedDates Set tscEvtID = " & lngEvtID & _
", tscPartsID = " & lngPartsID & ", tscEmpID = " & lngEmpID &
",tscLocID = " & lngLocID & ",tscPosID = " & lngPosID & ",tscDepID = " &
lngDepId & ",tscTypID = " & lngTypID & ",tscStartTime =#" & Me.txtStartTime &
_
"#, tscEndTime = #" & Me.txtEndTime & _
"#, tscCallTime = #" & Me.txtCallTime & _
"#, tscOutTime = #" & Me.txtOutTime & "#"
If Len(varNotes & "") > 0 Then
strSQL = strSQL & ", tscNotes = " & IIf(IsNull(varNotes), Null,
"""" & varNotes & """")
End If
db.Execute strSQL, dbFailOnError
End If
Sorry for giving the whole thing, but I don't have a clue where the problem
is. Any help with this would be greatly appreciated.
I am getting the error
"Run-time error '3075':
Syntax error (missing operator) in query expression 'Joshua McLemore'.
The 'Joshua McLemore' is the field lngEmpID I'm trying to insert below.
The error on debug then highlights the first db.Execute strSQL,
dbFailOnError in the code below:
Private Sub cmdBuildSchedule_Click()
Dim datThis As Date
Dim lngEvtID As String
Dim lngLocID As String
Dim lngPartsID As String
Dim lngEmpID As String
Dim lngPosID As String
Dim lngDepId As String
Dim lngTypID As String
Dim varNotes As Variant
Dim strSQL As String
Dim db As DAO.Database
Dim intDOW As Integer 'day of week
Dim intDIM As Integer 'Day in month
If Me.grpRepeats = 2 Then
If Not CheckDates() Then
Exit Sub
End If
End If
If Not CheckTimes() Then
Exit Sub
End If
If IsNull(Me.cboActID) Then
MsgBox "You must select an Event Name.", vbOKOnly + vbInformation,
"Enter Event Name"
Me.cboActID.SetFocus
Me.cboActID.Dropdown
Exit Sub
End If
If IsNull(Me.cboLocID) Then
MsgBox "You must select a Location.", vbOKOnly + vbInformation,
"Enter Location"
Me.cboLocID.SetFocus
Me.cboLocID.Dropdown
Exit Sub
End If
varNotes = Me.txtNotes
lngLocID = Me.cboLocID
lngEvtID = Me.cboActID
lngPartsID = Me.cboPartID
lngEmpID = Me.cboEmpID
lngPosID = Me.cboPosID
lngDepId = Me.cboDepID
lngTypID = Me.cboTypID
Set db = CurrentDb
If Me.grpRepeats = 2 Then 'need to loop through dates
For datThis = Me.txtStartDate To Me.txtEndDate
intDIM = GetDIM(datThis)
intDOW = Weekday(datThis)
If Me("chkDay" & intDIM & intDOW) = True Or _
Me("chkDay0" & intDOW) = True Then
strSQL = "INSERT INTO tblTempSchedDates (" & _
"tscDate, tscEvtID, tscPartsID, tscEmpID, tscLocID,
tscPosID, tscDepID, tscTypID, " & _
"tscStartTime, tscEndTime, tscCallTime, tscOutTime,
tscNotes ) " & _
"Values(#" & datThis & "#," & lngEvtID & "," &
lngPartsID & "," & lngEmpID & "," & lngLocID & "," & lngPosID & "," &
lngDepId & ", " & _
lngTypID & ", #" & Me.txtStartTime & "#, #" & _
Me.txtEndTime & "#, #" & _
Me.txtCallTime & "#, #" & _
Me.txtOutTime & "#," & _
IIf(IsNull(varNotes), "Null", """" & varNotes & """") &
")"
db.Execute strSQL, dbFailOnError
End If
Next
Else 'dates are there, just add the title, notes, times, location,
Activity
strSQL = "Update tblTempSchedDates Set tscEvtID = " & lngEvtID & _
", tscPartsID = " & lngPartsID & ", tscEmpID = " & lngEmpID &
",tscLocID = " & lngLocID & ",tscPosID = " & lngPosID & ",tscDepID = " &
lngDepId & ",tscTypID = " & lngTypID & ",tscStartTime =#" & Me.txtStartTime &
_
"#, tscEndTime = #" & Me.txtEndTime & _
"#, tscCallTime = #" & Me.txtCallTime & _
"#, tscOutTime = #" & Me.txtOutTime & "#"
If Len(varNotes & "") > 0 Then
strSQL = strSQL & ", tscNotes = " & IIf(IsNull(varNotes), Null,
"""" & varNotes & """")
End If
db.Execute strSQL, dbFailOnError
End If
Sorry for giving the whole thing, but I don't have a clue where the problem
is. Any help with this would be greatly appreciated.