report to excell

C

Cynthia

I have a report that runs off a query and also has a field that calls up a
function
i.e. =ListCircRoute([CIRCID]) the function ListCircRoute finds all the items
each circuit is routed through (i pasted this at end). This runs slow, I
tried calling the function from the query and it is even slower. My second
problem is I have to export this out to excell at the same time they view the
report. The only way I know of is to use the transferspreadsheet and send a
separte query that has the function in it. This is causing the database to
call up this information once for the report and again for the excell dump.
Is there any way I
can get this to dump the report thru vb code with out recalling the query?

This is how I currently get the report and excell dump
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryCircuitSchtExcell", StrLoc
DoCmd.OpenReport stDocName, acPreview

Here is my function
Public Function ListCircRoute(lngCircID) As String
Dim cn As Object
Dim rs As Object
Dim strsql As String
Dim strCircuits As String
' Initilize connection and recordset objects
Set cn = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")

If IsNull(lngCircID) Then lngCircID = -5

strsql = "SELECT qryCircuitRouteID.RouteDesc, qryCircuitRouteID.RouteNum
FROM qryCircuitRouteID WHERE (((qryCircuitRouteID.CircID)=" & lngCircID & "))
ORDER BY qryCircuitRouteID.RouteNum;"
Debug.Print strsql
rs.Open strsql, cn, 1

' Loop through recordset and add drawing names
If (rs.EOF) Then
strCircuits = ""
Else
With rs
Do While Not (.EOF)
strCircuits = strCircuits & "[" & !RouteNum & "]" &
!RouteDesc & ", "
.MoveNext
Loop
End With
End If

' Trim trailing ", "
If Not (strCircuits = "") Then strCircuits = Left$(strCircuits,
Len(strCircuits) - 2)
ListCircRoute = strCircuits
rs.Close 'added 061406

End Function
 

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

Top