K
Keith G Hicks
This is for a report in A2002 (A2k format). It's an ADP. The backend is SQL
2k.
I'm using virtually the same code for 4 reports so far. The only difference
is the name of the stored procedure and the list of params. The code below
runs without any errors in each of the 4 situation. Each of the stored
procedures in question when run in QA and using the same parameter values
I'm using in my front end runs without errors and returns rows. There are no
problems with the stored procedures. They all test out fine. Additionally,
as far as I can see, there are no differences in the properties of each of
the 4 reports that would cause me any problems. I would expect all 4 reports
to preview the data I see in QA. However, that is not the case. 2 of the
reports seem to work fine while the other 2 do not. The 2 that do not work
correctly display either #Name? or #Error in the text boxes where I'd expect
correct data to show up. I also get errors that fields "Access can't find
the field 'CompName' referred to in your expression." But it's clearly there
because when I run in debug and type ?rs!CompName in the immediate window I
get the value I'd expect. It's as if the ADP is screwed up and doesn't know
what to do sometimes. It gets confused. I also get no data errors on one of
them when that should clearly not be happening.
Here's my code:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
With cmd
Set .ActiveConnection = cnnCurrProj
.CommandType = adCmdStoredProc
.CommandTimeout = 0
.CommandText = "RptSales"
.Parameters.Append .CreateParameter("@RETURN_VALUE", adInteger,
adParamReturnValue)
.Parameters.Append .CreateParameter("@GetSaleDate", adVarChar,
adParamInput, 10, Format(dteGetDate, "mm/dd/yyyy"))
.Parameters.Append .CreateParameter("@Counties", adVarChar,
adParamInput, 8000, strGetCounties)
End With
rs.Open cmd, , adOpenStatic, adLockReadOnly
If cmd.Parameters.Item("@RETURN_VALUE").Value <> 0 Then 'error handling
MsgBox "Error getting report data (" &
Trim(str(cmd.Parameters.Item("@RETURN_VALUE").Value)) & ")"
Cancel = True
Call Report_Close
GoTo Exit_Report_Open
End If
Set Me.Recordset = rs
DoCmd.Maximize
Exit_Report_Open:
Exit Sub
Err_Report_Open:
MsgBox Err.Description & ", # " & str(Err.Number)
Resume Exit_Report_Open
End Sub
Any ideas? Are ADP's so screwed up that this sort of unpredictable behavior
occur?
Thanks,
Keith
2k.
I'm using virtually the same code for 4 reports so far. The only difference
is the name of the stored procedure and the list of params. The code below
runs without any errors in each of the 4 situation. Each of the stored
procedures in question when run in QA and using the same parameter values
I'm using in my front end runs without errors and returns rows. There are no
problems with the stored procedures. They all test out fine. Additionally,
as far as I can see, there are no differences in the properties of each of
the 4 reports that would cause me any problems. I would expect all 4 reports
to preview the data I see in QA. However, that is not the case. 2 of the
reports seem to work fine while the other 2 do not. The 2 that do not work
correctly display either #Name? or #Error in the text boxes where I'd expect
correct data to show up. I also get errors that fields "Access can't find
the field 'CompName' referred to in your expression." But it's clearly there
because when I run in debug and type ?rs!CompName in the immediate window I
get the value I'd expect. It's as if the ADP is screwed up and doesn't know
what to do sometimes. It gets confused. I also get no data errors on one of
them when that should clearly not be happening.
Here's my code:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
With cmd
Set .ActiveConnection = cnnCurrProj
.CommandType = adCmdStoredProc
.CommandTimeout = 0
.CommandText = "RptSales"
.Parameters.Append .CreateParameter("@RETURN_VALUE", adInteger,
adParamReturnValue)
.Parameters.Append .CreateParameter("@GetSaleDate", adVarChar,
adParamInput, 10, Format(dteGetDate, "mm/dd/yyyy"))
.Parameters.Append .CreateParameter("@Counties", adVarChar,
adParamInput, 8000, strGetCounties)
End With
rs.Open cmd, , adOpenStatic, adLockReadOnly
If cmd.Parameters.Item("@RETURN_VALUE").Value <> 0 Then 'error handling
MsgBox "Error getting report data (" &
Trim(str(cmd.Parameters.Item("@RETURN_VALUE").Value)) & ")"
Cancel = True
Call Report_Close
GoTo Exit_Report_Open
End If
Set Me.Recordset = rs
DoCmd.Maximize
Exit_Report_Open:
Exit Sub
Err_Report_Open:
MsgBox Err.Description & ", # " & str(Err.Number)
Resume Exit_Report_Open
End Sub
Any ideas? Are ADP's so screwed up that this sort of unpredictable behavior
occur?
Thanks,
Keith