subform on current firing thrice

rkmaitra

Registered User.
Local time
Today, 13:18
Joined
Jul 11, 2011
Messages
40
Hello,
I have a continuous form based on a table (tblRKM_Halifax_CA_2010) and a subform (subfrmAppend) based on the same table. The linked fields are Recno - therefore, the subform displays and allows edits on the record that is clicked on the continuous form.
All is working well, but I have noticed when stepping through my subform OnCurrent event that the event fires 3 times when I click a record on the parent form. Can anyone tell me why and if there is a way to prevent this from happening? It is not causing any errors, but the screen flickers 3 times every time I click on a blank record (in order to add a new entry) and that is annoying. I am providing the code for the OnCurrent event of the subform below:


Private Sub Form_Current()

If IsNull(Recno) Then
Dim lngRecno2 As Long
glngmRecno = 1 + DMax("[Recno]", "tblRKM_Halifax_CA_2010")
lngRecno2 = glngmRecno - 8

Forms!frmRKM_Halifax_CA_2010!subfrmAppend!Recno.SetFocus
Recno = glngmRecno
Forms!frmRKM_Halifax_CA_2010.Requery
DoCmd.GoToRecord , , , lngRecno2

DoCmd.GoToRecord , , acLast

End If
End Sub

NB - the event fires 3 times even if it does not enter the if-then loop.

Thanks in advance,
Rudra
 
Rudra,

It is possible for the subform to fire a few times especially when there's code in the Current event of the parent form, I've seen this behaviour. It may have something to do with the main form refreshing the link between it and the subform to ensure that they are in synch. It doesn't always happen though.

But just because we conclude that it's firing a few times, do you have any code that calls this Current event? Also, when you step through the code you say that it never enters the loop?
 
Thanks for the response. The event enters the loop when appropriate, and works just fine. It is just that as a result of it firing 3 times, my screen flickers 3 times - that is just annoying, no other problems.
 
Like I previously asked, do you have any code that calls the Current event?
 

Users who are viewing this thread

Back
Top Bottom