F
frank
I have a query with a function call that is used as the
recordsource for a listbox. The queries performance is
slow due to the function call and/or function design. I
was hoping to get some ideas on speeding things up. I
needed to display in a list box, descriptions (1 or many)
that are assigned to each piece of media. My approach was
to pass the Media_ID in a query to a function that will
return a text string with the following
format: "xxxx/xxxx/xxxx". This is working fine except
that it's very slow. Any suggestions?
Thanks in advance.
In the query, i call the function by; Internal #:
fGetInternalNumDesc(MediaID)
Public Function fGetInternalNumDesc(MediaID As Long) As
String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strInternalDesc As String
Set db = CurrentDb()
strSQL = "SELECT tblInternalNums.InternalNumDesc " & _
"FROM tblInternalNums INNER JOIN
tblMediaInternalNums " & _
"ON tblInternalNums.InternalNumID = " & _
"tblMediaInternalNums.InternalNumID " & _
"WHERE tblMediaInternalNums.MediaID=" & MediaID
Set rst = db.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
Do Until rst.EOF
strInternalDesc = strInternalDesc & "/" &
rst.Fields("InternalNumDesc")
rst.MoveNext
Loop
End If
If Len(strInternalDesc) > 0 Then
strInternalDesc = Right(strInternalDesc, Len
(strInternalDesc) - 1)
End If
fGetInternalNumDesc = strInternalDesc
End Function
recordsource for a listbox. The queries performance is
slow due to the function call and/or function design. I
was hoping to get some ideas on speeding things up. I
needed to display in a list box, descriptions (1 or many)
that are assigned to each piece of media. My approach was
to pass the Media_ID in a query to a function that will
return a text string with the following
format: "xxxx/xxxx/xxxx". This is working fine except
that it's very slow. Any suggestions?
Thanks in advance.
In the query, i call the function by; Internal #:
fGetInternalNumDesc(MediaID)
Public Function fGetInternalNumDesc(MediaID As Long) As
String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strInternalDesc As String
Set db = CurrentDb()
strSQL = "SELECT tblInternalNums.InternalNumDesc " & _
"FROM tblInternalNums INNER JOIN
tblMediaInternalNums " & _
"ON tblInternalNums.InternalNumID = " & _
"tblMediaInternalNums.InternalNumID " & _
"WHERE tblMediaInternalNums.MediaID=" & MediaID
Set rst = db.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
Do Until rst.EOF
strInternalDesc = strInternalDesc & "/" &
rst.Fields("InternalNumDesc")
rst.MoveNext
Loop
End If
If Len(strInternalDesc) > 0 Then
strInternalDesc = Right(strInternalDesc, Len
(strInternalDesc) - 1)
End If
fGetInternalNumDesc = strInternalDesc
End Function