Posted in Programming but no answer

C

cvegas

When I run this code it takes up 100% of my cpu time. I think it's because
of the findfirst on a very large sql table but don't know how to change it
to work properly.

Any advise would be appreciated.

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[OrderID] = " & Me![Combo87] & ""
If rs.NoMatch Then
MsgBox " The OrderID in not in the Orders"
Me.Rest.SetFocus
Else
Me.Bookmark = rs.Bookmark
If [Type of Order] = 1 Then
DoCmd.OpenForm "edit orders FROMHISTORY", , , "Orderid =" &
OrderID
Else
DoCmd.OpenForm "edit outbound orders FROMHISTORY", , , "Orderid
=" & OrderID
End If

End If
Set rs = Nothing
End Sub
 
R

Rick Brandt

cvegas said:
When I run this code it takes up 100% of my cpu time. I think it's
because of the findfirst on a very large sql table but don't know how
to change it to work properly.

Any advise would be appreciated.

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[OrderID] = " & Me![Combo87] & ""
If rs.NoMatch Then
MsgBox " The OrderID in not in the Orders"
Me.Rest.SetFocus
Else
Me.Bookmark = rs.Bookmark
If [Type of Order] = 1 Then
DoCmd.OpenForm "edit orders FROMHISTORY", , , "Orderid =" &
OrderID
Else
DoCmd.OpenForm "edit outbound orders FROMHISTORY", , ,
"Orderid =" & OrderID
End If

End If
Set rs = Nothing
End Sub

Don't use Find on an ODBC linked table. Apply a filter and it will likely be
near instant as that request will be sent to the server. A Find is pulling the
whole RecordSet over the wire so it can be scanned.

The code strategy you have there is common in Acces/Jet apps but it needs to be
discarded when using a server back end.
 
C

cvegas

I'm not the shapest tack in the box and have a huge project to get done ASAP.

Would you be kind enough to help me with the code that filters the record
and pulls it up to the screen so that I can edit the correct record?

Thanks either way.

Chuck

Rick Brandt said:
cvegas said:
When I run this code it takes up 100% of my cpu time. I think it's
because of the findfirst on a very large sql table but don't know how
to change it to work properly.

Any advise would be appreciated.

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[OrderID] = " & Me![Combo87] & ""
If rs.NoMatch Then
MsgBox " The OrderID in not in the Orders"
Me.Rest.SetFocus
Else
Me.Bookmark = rs.Bookmark
If [Type of Order] = 1 Then
DoCmd.OpenForm "edit orders FROMHISTORY", , , "Orderid =" &
OrderID
Else
DoCmd.OpenForm "edit outbound orders FROMHISTORY", , ,
"Orderid =" & OrderID
End If

End If
Set rs = Nothing
End Sub

Don't use Find on an ODBC linked table. Apply a filter and it will likely be
near instant as that request will be sent to the server. A Find is pulling the
whole RecordSet over the wire so it can be scanned.

The code strategy you have there is common in Acces/Jet apps but it needs to be
discarded when using a server back end.
 
R

Rick Brandt

cvegas said:
I'm not the shapest tack in the box and have a huge project to get
done ASAP.

Would you be kind enough to help me with the code that filters the
record and pulls it up to the screen so that I can edit the correct
record?

Thanks either way.

Me.Filter = "[OrderID] = " & Me![Combo87] & ""
Me.FilterOn = True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top