A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

dcount



 
 
Thread Tools Display Modes
  #1  
Old November 5th, 2009, 07:31 AM posted to microsoft.public.access.queries
igg via AccessMonster.com
external usenet poster
 
Posts: 35
Default dcount

PatientTable contains thousands of patient records. subform current record
selection should for a given clinic ID, update the parent totalpatients text
box with total number of patients in good health. But the
update is slow. like to speed it up so that a current record selection,
updates the text box almost immediately.

Private Sub Form_Current()
Me.Parent.totalpatients = DCount("patient", "PatientTable", "patient='Good'
And ClinicID='" & Me.Parent.Clinic_ID & "'")
End Sub

--
Message posted via http://www.accessmonster.com

  #2  
Old November 5th, 2009, 08:34 AM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default dcount

hi,

igg via AccessMonster.com wrote:
update is slow. like to speed it up so that a current record selection,
updates the text box almost immediately.

Private Sub Form_Current()
Me.Parent.totalpatients = DCount("patient", "PatientTable", "patient='Good'
And ClinicID='" & Me.Parent.Clinic_ID & "'")
End Sub

The most important step:
Create a combined index in your table [PatientTable] and add the two
fields [Patient] and [ClinicID] (in this order).

Is your parent form bound or unbound? Does Me.Parent.Clinic_ID reference
a bound field or an unbound control?


mfG
-- stefan --
  #3  
Old November 5th, 2009, 12:45 PM posted to microsoft.public.access.queries
igg via AccessMonster.com
external usenet poster
 
Posts: 35
Default dcount

parent form is unbound. And, Me.Parent.Clinic_ID is also unbound.

Stefan Hoffmann wrote:
hi,

update is slow. like to speed it up so that a current record selection,
updates the text box almost immediately.

[quoted text clipped - 3 lines]
And ClinicID='" & Me.Parent.Clinic_ID & "'")
End Sub

The most important step:
Create a combined index in your table [PatientTable] and add the two
fields [Patient] and [ClinicID] (in this order).

Is your parent form bound or unbound? Does Me.Parent.Clinic_ID reference
a bound field or an unbound control?

mfG
-- stefan --


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1

  #4  
Old November 5th, 2009, 01:13 PM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default dcount

hi,

igg via AccessMonster.com wrote:
The most important step:
Create a combined index in your table [PatientTable] and add the two
fields [Patient] and [ClinicID] (in this order).
Is your parent form bound or unbound? Does Me.Parent.Clinic_ID reference
a bound field or an unbound control?

Okay. Adding the index did work?



mfG
-- stefan --
  #5  
Old November 5th, 2009, 08:53 PM posted to microsoft.public.access.queries
igg via AccessMonster.com
external usenet poster
 
Posts: 35
Default dcount

original remote table is being used and I can not modify it. i copied the
original database to a different remote folder with no user connected to it
and noticed significant improvement in speed. By adding a combined index you
do not mean adding a new column to the table, right?. just go to design view
and create an combined index of the two, right?.

Stefan Hoffmann wrote:
hi,

The most important step:
Create a combined index in your table [PatientTable] and add the two
fields [Patient] and [ClinicID] (in this order).
Is your parent form bound or unbound? Does Me.Parent.Clinic_ID reference
a bound field or an unbound control?

Okay. Adding the index did work?

mfG
-- stefan --


--
Message posted via http://www.accessmonster.com

  #6  
Old November 6th, 2009, 08:39 AM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default dcount

hi,

igg via AccessMonster.com wrote:
original remote table is being used and I can not modify it. i copied the
original database to a different remote folder with no user connected to it
and noticed significant improvement in speed.

This should only be the case if the new remote location is on another
server/drive.

But there is another optimization you may try: A permanent recordset.

Create a form with this events filled:

Option Compare Database
Option Explicit

Private m_Recordset As DAO.Recordset

Private Sub Form_Load()

Set m_Recordset = CurrentDb.OpenRecordset( _
"anyRemoteTable", dbOpenDynamic)

End Sub

Private Sub Form_Close()

m_Recordset.Close
Set m_Recordset = Nothing

End Sub

ACE/Jet will create the lock file (.ldb) once. So this saves file I/O.

By adding a combined index you
do not mean adding a new column to the table, right?. just go to design view
and create an combined index of the two, right?.

Yes. No new columns, only the index.


mfG
-- stefan --
  #7  
Old November 6th, 2009, 08:57 PM posted to microsoft.public.access.queries
igg via AccessMonster.com
external usenet poster
 
Posts: 35
Default dcount

your first suggested optimization to create combo index worked very well. for
the second optimization that you have suggested, just use the form already i
am using or should i create a new form?. Just making sure. these should get
added to the form i use to do queries, right?. Thanks.

Stefan Hoffmann wrote:
hi,

original remote table is being used and I can not modify it. i copied the
original database to a different remote folder with no user connected to it
and noticed significant improvement in speed.

This should only be the case if the new remote location is on another
server/drive.

But there is another optimization you may try: A permanent recordset.

Create a form with this events filled:

Option Compare Database
Option Explicit

Private m_Recordset As DAO.Recordset

Private Sub Form_Load()

Set m_Recordset = CurrentDb.OpenRecordset( _
"anyRemoteTable", dbOpenDynamic)

End Sub

Private Sub Form_Close()

m_Recordset.Close
Set m_Recordset = Nothing

End Sub

ACE/Jet will create the lock file (.ldb) once. So this saves file I/O.

By adding a combined index you
do not mean adding a new column to the table, right?. just go to design view
and create an combined index of the two, right?.

Yes. No new columns, only the index.

mfG
-- stefan --


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1

  #8  
Old November 7th, 2009, 11:55 AM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default dcount

hi,

igg via AccessMonster.com wrote:
your first suggested optimization to create combo index worked very well. for
the second optimization that you have suggested, just use the form already i
am using or should i create a new form?. Just making sure. these should get
added to the form i use to do queries, right?. Thanks.

No, explicitly a new form.

Open it as soon as possible after your application has started using
WindowMode := acHidden, so that the users doesn't see it.

mfG
-- stefan --
  #9  
Old November 7th, 2009, 06:30 PM posted to microsoft.public.access.queries
igg via AccessMonster.com
external usenet poster
 
Posts: 35
Default dcount

is it possible to have the main form to start this new form and close when it
exits?. if yes, how?.

Stefan Hoffmann wrote:
hi,

your first suggested optimization to create combo index worked very well. for
the second optimization that you have suggested, just use the form already i
am using or should i create a new form?. Just making sure. these should get
added to the form i use to do queries, right?. Thanks.

No, explicitly a new form.

Open it as soon as possible after your application has started using
WindowMode := acHidden, so that the users doesn't see it.

mfG
-- stefan --


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1

  #10  
Old November 9th, 2009, 09:36 AM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default dcount

hi,

igg via AccessMonster.com wrote:
is it possible to have the main form to start this new form and close when it
exits?. if yes, how?.

Use the main forms Load event, e.g.:

Private Sub Form_Load()

DoCmd.OpenForm FormName := "formWithPermanentRecordset", _
WindowMode := acHidden

End Sub


mfG
-- stefan --
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.