dynamictiger
Technical User
Below is a sub that is not working. Problem is i do not know where the fault is.
The SQL statement I am using is based on a query that does work, so I do not think the error is in there.
The problem is that if I pass the datCurrentServiceDate as the 12th of August, and intServicePerson as 2, I get 0 records returned.
If I then open the form and run the query I am returning the two jobs previously booked for service person 2 on 12/8/02.
As you can see I have started to break down the SQL statement by removing and commenting out the serviceperson lines, but this returns 0 records too.
I am not too familiar with ADO, so I could have made an error in setting this up.
Any help, advice, guesses or stabs in the dark welcome.
Private Sub DecideTime()
'We SQL statement to have a look at the individual diary and derive a time
'based on estimates in previous jobs as to when teh service person should be on site
'if the time is promised we add an extra allowance on both sides
Dim rstTime As ADODB.Recordset
Dim datCurrentServiceDate As Date
Dim intServicePerson As Integer
Set rstTime = New ADODB.Recordset
'Allocate the calculated service date to the SQL statement
datCurrentServiceDate = Format(Me.ServiceDate, "Medium Date"
'Allocate the passed in serviceperson as the nominated service diary
intServicePerson = Me.ServicePerson
Debug.Print datCurrentServiceDate & " " & intServicePerson
rstTime.Open "SELECT tblServiceTime.ServiceDate, tblServiceTime.ServiceRequired, " & _
"tblServiceTime.TimePromised, tblServiceTime.AllowedTime, " & _
"tblServiceTime.ServicePerson, " & _
"DateAdd('h',[AllowedTime],[TimePromised]) AS NextTime " & _
"FROM tblServiceTime " & _
"WHERE (((tblServiceTime.ServiceDate) = " & _
"#" & datCurrentServiceDate & " #)) " & _
"WITH OWNERACCESS OPTION;", _
CurrentProject.Connection, adOpenStatic
Debug.Print rstTime.RecordCount
' "And ((tblServiceTime.ServicePerson) = " & _
" " & intServicePerson & "
) "
Do
Debug.Print rstTime!NextTime
rstTime.MoveNext
Loop Until rstTime.EOF
End Sub
The SQL statement I am using is based on a query that does work, so I do not think the error is in there.
The problem is that if I pass the datCurrentServiceDate as the 12th of August, and intServicePerson as 2, I get 0 records returned.
If I then open the form and run the query I am returning the two jobs previously booked for service person 2 on 12/8/02.
As you can see I have started to break down the SQL statement by removing and commenting out the serviceperson lines, but this returns 0 records too.
I am not too familiar with ADO, so I could have made an error in setting this up.
Any help, advice, guesses or stabs in the dark welcome.
Private Sub DecideTime()
'We SQL statement to have a look at the individual diary and derive a time
'based on estimates in previous jobs as to when teh service person should be on site
'if the time is promised we add an extra allowance on both sides
Dim rstTime As ADODB.Recordset
Dim datCurrentServiceDate As Date
Dim intServicePerson As Integer
Set rstTime = New ADODB.Recordset
'Allocate the calculated service date to the SQL statement
datCurrentServiceDate = Format(Me.ServiceDate, "Medium Date"
'Allocate the passed in serviceperson as the nominated service diary
intServicePerson = Me.ServicePerson
Debug.Print datCurrentServiceDate & " " & intServicePerson
rstTime.Open "SELECT tblServiceTime.ServiceDate, tblServiceTime.ServiceRequired, " & _
"tblServiceTime.TimePromised, tblServiceTime.AllowedTime, " & _
"tblServiceTime.ServicePerson, " & _
"DateAdd('h',[AllowedTime],[TimePromised]) AS NextTime " & _
"FROM tblServiceTime " & _
"WHERE (((tblServiceTime.ServiceDate) = " & _
"#" & datCurrentServiceDate & " #)) " & _
"WITH OWNERACCESS OPTION;", _
CurrentProject.Connection, adOpenStatic
Debug.Print rstTime.RecordCount
' "And ((tblServiceTime.ServicePerson) = " & _
" " & intServicePerson & "
Do
Debug.Print rstTime!NextTime
rstTime.MoveNext
Loop Until rstTime.EOF
End Sub