What is the correct way to handle Form_Current event?
I'm finding it runs many times while I am initialising various controls in my startup Form.
The only way I've found to stop it is Me.OnCurrent = "" in Form load. (And later Forms!Form1.OnCurrent = "[Event Procedure]")
But this prevents Form Current running at all, until I move to another record. So I have my own Current event to call as I want.
But I feel there's something wrong and I should be able to use the native Access functions.
Startup Form
Main Form
I'm finding it runs many times while I am initialising various controls in my startup Form.
The only way I've found to stop it is Me.OnCurrent = "" in Form load. (And later Forms!Form1.OnCurrent = "[Event Procedure]")
But this prevents Form Current running at all, until I move to another record. So I have my own Current event to call as I want.
But I feel there's something wrong and I should be able to use the native Access functions.
Startup Form
Code:
Private Sub Form_Load()
Dim Yr As String
Dim Path As String
Path = BrowseFolder("Enter Path To Check")
If Path > "" Then
Yr = YrFromPath(Path)
If Yr > "" Then
DoCmd.OpenForm "Form1", acNormal
Forms!Form1.RecordSource = "Select * from qryBB Where Year = '" & Yr & "';"
Forms!Form1.txtPrefix.ControlSource = "Prefix"
Forms!Form1.lblPath.Caption = Path
DoCmd.Close acForm, "frmStartup"
Forms!Form1.OnCurrent = "[Event Procedure]"
Forms!Form1.MyCurrent
Else
MsgBox "No Year found in " & Path
End If
Else
MsgBox "No Path Supplied"
End If
End Sub
Code:
Private Sub Form_Current()
Debug.Print "Current"
MyCurrent
End Sub
Private Sub Form_Load()
Me.OnCurrent = ""
End Sub
Public Sub MyCurrent()
Debug.Print "MyCurrent"
Dim files As Variant
ReDim files(0)
Me.txtPrefix.ControlSource = "Prefix"
If FolderExists(Me.lblPath.Caption) = True Then
files = gFindFiles(Me.lblPath.Caption, Me!Prefix & "*.jpg", False)
End If
Me.lblImageCount.Caption = "Images Found: " & UBound(files)
End Sub