I use the following code to locate and display records on an access form. The data resides in SQL Server 2000. Performance of this screen is slow. Can anyone recommend improvements in this code to increase performance? Thanks.
Private Sub Form_Load()
Dim strCriteria As String
Dim rst As Recordset
' Initialize the recordset
Set rst = Me.RecordsetClone
' Set the flag that indicates the origin of movement through records
fFromListBox = False
' Create the criteria string then search for a record matching the criteria
strCriteria = "([SECQTY] = 0 OR IsNull([Secqty])) AND ([EDIQTY] = 0 OR IsNull([EDIQTY])) AND ([NAVQTY] = 0 OR IsNull([NAVQTY]))"
rst.FindFirst strCriteria
' If a match is found, move to that record and set the value of the list box
' to equal the ID of the record that matches the criteria. Otherwise,
' display a message
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
Me!QtyList = Me!ItemID
Else
MsgBox "No undistributed orders found!", vbOKOnly + vbExclamation
Me!QtyList = Me!ItemID
End If
Me!QtyList.Requery
' Release memory claimed by the variable
Set rst = Nothing
End Sub
Private Sub Form_Load()
Dim strCriteria As String
Dim rst As Recordset
' Initialize the recordset
Set rst = Me.RecordsetClone
' Set the flag that indicates the origin of movement through records
fFromListBox = False
' Create the criteria string then search for a record matching the criteria
strCriteria = "([SECQTY] = 0 OR IsNull([Secqty])) AND ([EDIQTY] = 0 OR IsNull([EDIQTY])) AND ([NAVQTY] = 0 OR IsNull([NAVQTY]))"
rst.FindFirst strCriteria
' If a match is found, move to that record and set the value of the list box
' to equal the ID of the record that matches the criteria. Otherwise,
' display a message
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
Me!QtyList = Me!ItemID
Else
MsgBox "No undistributed orders found!", vbOKOnly + vbExclamation
Me!QtyList = Me!ItemID
End If
Me!QtyList.Requery
' Release memory claimed by the variable
Set rst = Nothing
End Sub