Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-29-2005, 08:50 AM   #1
maacky99
Access Newbie
 
Join Date: Jun 2004
Location: Detroit, MI USA
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
maacky99 is on a distinguished road
On change event in form

I have a field (AR#) that has an "on change" event. This is supposed to check through the database and see if that number has been here before (it's like a job # / serial #). It had always worked fine - now suddenly this field, and this field only, reacts VERY, VERY slowly when you type a number in. You can type the number and wait about 5 seconds for it to show up. When I removed the event - it acted normally so I think it has to do with that. Here's the vb for the event:

Private Sub AR__Change()
Dim db As Database
Dim Rst As DAO.Recordset
Dim strAR As String
Set db = CurrentDb()
strAR = Me.AR_.Text
Set Rst = db.OpenRecordset("repairs", dbOpenDynaset)
Rst.FindFirst "[AR#] = '" & strAR & "'"
If Rst.NoMatch Then
Else
MsgBox ("This value it is already in the system !")
End If
End Sub


Any ideas why it's reacting so slow or what I should look for?

maacky99 is offline   Reply With Quote
Old 09-29-2005, 09:12 AM   #2
freakazeud
AWF VIP
 
freakazeud's Avatar
 
Join Date: Sep 2005
Location: MD, USA
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
freakazeud is on a distinguished road
Hi,
why are you doing this on the on change event? This means everytime a change in the field occures the application will open the recordset, check if the value is in there already and do something based on that. This obviously would slow things down a lot. You should put this code on the before update event of the control. This way the check will just happen ones when the "whole" value is typed in and can be evaluated against values in the recordset.
HTH
Good luck
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
freakazeud is offline   Reply With Quote
Old 09-29-2005, 10:59 AM   #3
maacky99
Access Newbie
 
Join Date: Jun 2004
Location: Detroit, MI USA
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
maacky99 is on a distinguished road
This database was set up before me, so I'm not sure. The thing I don't understand is that it never did this before - everything had been fine for a few years.

I know we wanted to flag it as we were checking the part in so we would know if it was a warranty or not.

Any other ideas?

maacky99 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
change the backcolor of subform in the form ranen Modules & VBA 1 06-29-2005 02:04 PM
two txt field owrking either way on change event mel9338 Forms 1 01-10-2005 02:55 PM
Checking all fields on a form for change trickg Forms 1 11-26-2002 04:10 PM
Close and Delete Form on On_Load Event BigJimSlade Modules & VBA 15 09-17-2002 06:54 AM
change event of the text box reena Modules & VBA 0 08-02-2001 12:25 PM




All times are GMT -8. The time now is 06:14 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World