I have a report that I have been running for a while and now it seems to have slowed down. It takes over 15 minutes for me to process about 400 records and I don't know why.
The back end is on a file server. There's no problem with the connection - I am sure. I call a function for about 4 fields on a report. here's my code for the function. Are my connections not correct? I need advice ! Do you see anything wrong with my database connections?
Function fConcat(strChildTable As String, _
strIDName As String, _
strFldConcat As String, _
strIDType As String, _
varIDvalue As Variant) As String
Dim db As Database
Dim rs As ADODB.Recordset
Dim varConcat As Variant
Dim count As Integer
Dim strCriteria As String, strSql As String
On Error GoTo err_fconcat
varConcat = Null
Set db = CurrentDb
strSql = "select distinct [" & strFldConcat & "]from[" & strChildTable & "]"
strSql = strSql & "Where "
Select Case strIDType
Case "String":
strSql = strSql & "[" & strIDName & "]='" & varIDvalue & "'"
Case "Long", "Integer", "double":
strSql = strSql & "[" & strIDName & "] =" & varIDvalue
Case Else
GoTo err_fconcat
End Select
Set rs = db.OpenRecordset(strSql, dbOpenSnapshot)
With rs
If .RecordCount <> 0 Then
Do While Not rs.EOF
varConcat = varConcat & rs(strFldConcat) & ","
.MoveNext
Loop
End If
End With
fConcat = Left(varConcat, Len(varConcat) - 1)
end function
The back end is on a file server. There's no problem with the connection - I am sure. I call a function for about 4 fields on a report. here's my code for the function. Are my connections not correct? I need advice ! Do you see anything wrong with my database connections?
Function fConcat(strChildTable As String, _
strIDName As String, _
strFldConcat As String, _
strIDType As String, _
varIDvalue As Variant) As String
Dim db As Database
Dim rs As ADODB.Recordset
Dim varConcat As Variant
Dim count As Integer
Dim strCriteria As String, strSql As String
On Error GoTo err_fconcat
varConcat = Null
Set db = CurrentDb
strSql = "select distinct [" & strFldConcat & "]from[" & strChildTable & "]"
strSql = strSql & "Where "
Select Case strIDType
Case "String":
strSql = strSql & "[" & strIDName & "]='" & varIDvalue & "'"
Case "Long", "Integer", "double":
strSql = strSql & "[" & strIDName & "] =" & varIDvalue
Case Else
GoTo err_fconcat
End Select
Set rs = db.OpenRecordset(strSql, dbOpenSnapshot)
With rs
If .RecordCount <> 0 Then
Do While Not rs.EOF
varConcat = varConcat & rs(strFldConcat) & ","
.MoveNext
Loop
End If
End With
fConcat = Left(varConcat, Len(varConcat) - 1)
end function