Using 100% of CPU Time

G

Guest

When I run this code it takes up 100% of my cpu time. I think it's because
for the find first 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
 
S

Stefan Hoffmann

hi,
When I run this code it takes up 100% of my cpu time. I think it's because
for the find first but don't know how to change it to work properly.
Use

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Debug]
"JETSHOWPLAN"="ON"

to optimize your recordsource. You can't really draw a valid conclusion
from "100% cpu time".


mfG
--> stefan <--
 
D

Dirk Goldgar

cvegas said:
When I run this code it takes up 100% of my cpu time. I think it's
because for the find first 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

I wouldn't really expect a FindFirst to tie up your CPU in any
significant way. Of course, it's natural for Access 97 to use 100% CPU
time when idle; see KB article 160819:

http://support.microsoft.com/kb/160819/en-us
ACC: Microsoft Access Shows 100% CPU Utilization
During Idle Time

Is that what's going on here? If so, don't worry about it.

If you're using a later version of Access than 97, then what makes you
think you have a problem? Does your system become unresponsive, which
led you to check the CPU usage? How did you narrow the problem down to
this section of code? Did you isolate it to the FindFirst, or could it
be in the forms you're opening?
 
G

Guest

Using Access 2K. Have a combo box where we type in an indexed number It
finds the 1st 3 numbers very fast but the last 3 take forever. There are
about 35K records in the index.

Actuall this is the primary key in that table with no duplicates allowed.

I am hesitant to edit the register but will do so if necessary

Dirk Goldgar said:
cvegas said:
When I run this code it takes up 100% of my cpu time. I think it's
because for the find first 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

I wouldn't really expect a FindFirst to tie up your CPU in any
significant way. Of course, it's natural for Access 97 to use 100% CPU
time when idle; see KB article 160819:

http://support.microsoft.com/kb/160819/en-us
ACC: Microsoft Access Shows 100% CPU Utilization
During Idle Time

Is that what's going on here? If so, don't worry about it.

If you're using a later version of Access than 97, then what makes you
think you have a problem? Does your system become unresponsive, which
led you to check the CPU usage? How did you narrow the problem down to
this section of code? Did you isolate it to the FindFirst, or could it
be in the forms you're opening?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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