Hi All, I need urgent help here. I need to populate a listbox based on data input by users. I have many textboxes for inputting the data by users. Then these data will be set as parameters for the QueryDef. Below code works fine but the problem is: it takes so long time to populate the result on the list box. Can anybody let me know if there is a better way to do this? Thanks very much.
Dim qryQuote As DAO.QueryDef
Dim rec As DAO.Recordset
Set qryQuote = CurrentDb.QueryDefs("qry_ALL")
qryQuote.Parameters!test = Me.NGOName
qryQuote.Parameters!test1 = Me.DName
Set rec = qryQuote.OpenRecordset()
Me.lstResult.RowSource = rec("NGOName")
If rec.RecordCount <> 0 Then
With Me.lstResult
.RowSource = ""
Do Until rec.EOF
'TAKES AGES IN POPULATING RECORDS HERE
.AddItem """" & rec("NGOName") & """;""" & rec("DName") & """"
rec.MoveNext
Loop
.Requery
End With
Regards,
Sandra
Dim qryQuote As DAO.QueryDef
Dim rec As DAO.Recordset
Set qryQuote = CurrentDb.QueryDefs("qry_ALL")
qryQuote.Parameters!test = Me.NGOName
qryQuote.Parameters!test1 = Me.DName
Set rec = qryQuote.OpenRecordset()
Me.lstResult.RowSource = rec("NGOName")
If rec.RecordCount <> 0 Then
With Me.lstResult
.RowSource = ""
Do Until rec.EOF
'TAKES AGES IN POPULATING RECORDS HERE
.AddItem """" & rec("NGOName") & """;""" & rec("DName") & """"
rec.MoveNext
Loop
.Requery
End With
Regards,
Sandra