Form_Current Infinite Loop

  • Thread starter mdullni1 via AccessMonster.com
  • Start date
M

mdullni1 via AccessMonster.com

MSAccess 2003 frontend, SQL Server 2000 Backend

Hi,
I have a form with 6 tabs. The following code is in Form_Current to ensure
the form goes to the first tab when moving to another record.

Private Sub Form_Current()
'*****************************************************************************
'* Sub: Form_Current
*
'* Purpose: Sets backcolor on fields for current record. Sets Current Record
*
'* label to name of current student.
*
'*****************************************************************************
Me.lblCrntRcrd.Caption = "Current Record: " & Me.LNm & ", " & Me.FNm & " "
& Me.MNm

'reset tab change flags
mblntabPrsnl_Set = False
mblntabRcEthn_Set = False
mblntabCtzn_Set = False
mblntabAddr_Set = False
mblntabSchl_Set = False
mblntabSOMRqrd_Set = False
If Me!TabCtlGradAdms.Pages(Me!TabCtlGradAdms.value).Name = "tabPrsnl" Then
'**if already on first tab, invoke set up for next record
Call TabCtlGradAdms_Change
Else
'Change to first tab which will invoke setup (recall Form_Current)
Me.TabCtlGradAdms.Pages(0).SetFocus
End If

Exit_StdExit:
Exit Sub

End Sub

Sometimes Form_Current is invoked without changing records. I want to trap
for that so this code is not executed, but when I add at the beginning:

If mlngAppID = me.txtAppID then
goto Exit_StdExit
end if

The process re-executes Form_Current everytime it hits this statement,
causing an infinite loop.

I have seen other posts where this kind of thing was done, but for some
reason anytime I reference a control on this tab (second tab) Form_Current is
invoked.

Can anyone explain why and tell me how to stop the loop?

Thanks
 
M

mdullni1 via AccessMonster.com

FYI - this fixed my problem:

Me.txtAppID.SetFocus
If lngAppId = CLng(Me.txtAppID.Text) Then
GoTo Exit_StdExit
End If
lngAppId = Me.txtAppID.Text
 

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