Duane Hookum's Recurring DB example

Joined
Mar 10, 2007
Messages
1
Reaction score
0
Hi All
I've downloaded Duane Hookums Recurring DB and want to add a field to it. Ive added what I think is the necessary code but it now gives me an error which I can't track down. If anyone can help I'd be grateful.
Here is the section of code causing the problem.

Private Sub cmdBuildSchedule_Click()
Dim datThis As Date
Dim lngActID As Long
Dim lngLocID As Long
Dim varNotes As Variant
Dim SubContractor 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 Activity.", vbOKOnly + vbInformation, "Enter Activity"
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
If IsNull(Me.cboSubContractor) Then
MsgBox "You must select a SubContractor.", vbOKOnly + vbInformation, "Enter SubContractor"
Me.cboSubContractor.SetFocus
Me.cboSubContractor.Dropdown
Exit Sub
End If
'strTitle = Me.txtTitle
varNotes = Me.txtNotes
lngLocID = Me.cboLocID
lngActID = Me.cboActID
SubContractor = Me.cboSubContractor
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, tscActID, tscLocID, SubContractor, " & _
"tscStartTime, tscEndTime, tscNotes ) " & _
"Values(#" & datThis & "#," & lngActID & ", " & _
lngLocID & ", #" & Me.cboSubContractor & "#, #" & Me.txtStartTime & "#, #" & _
Me.txtEndTime & "#," & _
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 tscActID = " & lngActID & _
", tscLocID = " & lngLocID & ", tscStartTime =#" & Me.txtStartTime & _
"#, tscEndTime = #" & Me.txtEndTime & "#"

If Len(varNotes & "") > 0 Then
strSQL = strSQL & ", tscNotes = " & IIf(IsNull(varNotes), Null, """" & varNotes & """")
End If
db.Execute strSQL, dbFailOnError
End If
Me.sfrmTempScheduleEdit.Requery
MsgBox "Temporary schedule built. " & _
"You can now edit the schedule and " & _
"append to the permanent schedule.", vbOKOnly + vbInformation, "Temp schedule complete"
End Sub

I have highlighted what I believe is the offending part.
The error message is as follows.

Syntax error in date in query expression '#1#'.

Thanks in advance.

ChrisD

And many thanks to Duane and people like him for making their code available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top