Connecting Tech Pros Worldwide Forums | Help | Site Map

On Current Event not triggered

Member
 
Join Date: Aug 2007
Posts: 119
#1: Jul 9 '09
I have an intake form that is opened by clicking a control on a search form. This click runs a subroutine in the search form that uses DoCmd.OpenReport with stLinkCriteria.

In the intake form I have a subroutine that is set to run OnCurrent - Private Sub Form_Current().

Here's where it gets weird. When I open the intake form by clicking the control in the search form, the code does not run (the results would be visible on the screen).

However, if I put a Breakpoint in the code and open the form exactly the same way, it takes me directly to the code where I can F5 to run it.

What's going on? Has anyone seen this before?

ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,218
#2: Jul 9 '09

re: On Current Event not triggered


Quote:

Originally Posted by Annalyzer View Post

I have an intake form that is opened by clicking a control on a search form. This click runs a subroutine in the search form that uses DoCmd.OpenReport with stLinkCriteria.

In the intake form I have a subroutine that is set to run OnCurrent - Private Sub Form_Current().

Here's where it gets weird. When I open the intake form by clicking the control in the search form, the code does not run (the results would be visible on the screen).

However, if I put a Breakpoint in the code and open the form exactly the same way, it takes me directly to the code where I can F5 to run it.

What's going on? Has anyone seen this before?

How about displaying the code in the Control on the Search Form, as well as the code in the Current() Event of the Intake Form?
Member
 
Join Date: Aug 2007
Posts: 119
#3: Jul 9 '09

re: On Current Event not triggered


It's very simple code, really.

From the control on the search form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub memLast_Click()
  2. On Error GoTo Err_memLast_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stLinkCriteria = "hhId=" & Me.hhId
  8.     DoCmd.OpenForm "frmHousehold", , , stLinkCriteria
  9.  
  10.  
  11. Exit_memLast_Click:
  12.     Exit Sub
  13.  
  14. Err_memLast_Click:
  15.     MsgBox Err.Description
  16.     Resume Exit_memLast_Click
  17.  
  18. End Sub
And from the intake form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Dim monthCount, yearCount As Integer
  3.  
  4.     monthCount = Me![sfrmHiddenFBMonthCount].[Form]![txtFBCount]
  5.     If monthCount > 1 Then
  6.         Label34.Visible = False
  7.         txtBoxesThisMonth.Visible = False
  8.         Label35.Visible = False
  9.         lblExceededMonthLimit.Visible = True
  10.     End If
  11.  
  12.     yearCount = Me![sfrmFoodbox].[Form]![txtFBCount]
  13.     If yearCount > 11 Then
  14.         Label31.Visible = False
  15.         txtBoxesThisYear.Visible = False
  16.         Label32.Visible = False
  17.         lblExceededAnnualLimit.Visible = True
  18.     End If
  19. End Sub
I tried moving it to other events, but got the same results no matter where I put it. Is it because I'm relying on a value from the subform?
Member
 
Join Date: Aug 2007
Posts: 119
#4: Jul 9 '09

re: On Current Event not triggered


Got it. It did have to do with referring to a value from the subform. The value I was pulling was a total in a footer on the subform. As soon as I moved it to it's own hidden subform everything worked perfectly. Thanks for your help.
Reply


Similar Microsoft Access / VBA bytes