Hi!
I recently put a lot of procesing out of the query for a form into functions in a module. Then I noticed a delay in showing the data onto the form. For example I have a combobox on a bounded form, witch contains names of people. The combobox first had a query on it getting the full names of persons in one string, eg: select firstname & " " & middlename & " " & lastname from tblPersons where ... (simple example! real situation is much more dificult) Now I have a function containing:
Public Function full_name(in_p_id As Integer) As String
On Error Resume Next
Dim cnn As Connection
Dim rst As New ADODB.Recordset
Set cnn = CurrentProject.Connection
cnn.BeginTrans
rst.open "SELECT * FROM tblPerson where p_id = " & in_p_id, cnn, adOpenKeyset, adLockReadOnly, adCmdTableDirect
full_name = rst!firstname & " " & rst!middlename & " " & rst!lastname
end function
(again a simplified example)
When I go to the next record, the combobox shows it's values couples of 100ths of seconds later when I use the function. I thought ADO was relative fast? How can I speed this code up a litle?
Greets and thanks!
Tom
I recently put a lot of procesing out of the query for a form into functions in a module. Then I noticed a delay in showing the data onto the form. For example I have a combobox on a bounded form, witch contains names of people. The combobox first had a query on it getting the full names of persons in one string, eg: select firstname & " " & middlename & " " & lastname from tblPersons where ... (simple example! real situation is much more dificult) Now I have a function containing:
Public Function full_name(in_p_id As Integer) As String
On Error Resume Next
Dim cnn As Connection
Dim rst As New ADODB.Recordset
Set cnn = CurrentProject.Connection
cnn.BeginTrans
rst.open "SELECT * FROM tblPerson where p_id = " & in_p_id, cnn, adOpenKeyset, adLockReadOnly, adCmdTableDirect
full_name = rst!firstname & " " & rst!middlename & " " & rst!lastname
end function
(again a simplified example)
When I go to the next record, the combobox shows it's values couples of 100ths of seconds later when I use the function. I thought ADO was relative fast? How can I speed this code up a litle?
Greets and thanks!
Tom