On change event in form (1 Viewer)

maacky99

Access Newbie
Local time
Today, 01:16
Joined
Jun 3, 2004
Messages
35
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?
 

freakazeud

AWF VIP
Local time
Today, 02:16
Joined
Sep 10, 2005
Messages
221
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
 

maacky99

Access Newbie
Local time
Today, 01:16
Joined
Jun 3, 2004
Messages
35
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?
 

Users who are viewing this thread

Top Bottom