G
Guest
End if not needed with If in the following code. Could someone pls explain
about why it works this way.
My app has the public function IsLoaded and a sub for the OnClose event of a
form.
I have copied from Northwind, for the sub OnClose
The If statement is all on one line, and it doesn’t need an ‘End if’.
My question is why isn’t the ‘End if’ needed, or why set the code this way
instead of the more common:
If then
End if
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If
End Function
Private Sub Form_Close()
If IsLoaded("frmViewTracks") Then DoCmd.Close acForm, "frmViewTracks"
about why it works this way.
My app has the public function IsLoaded and a sub for the OnClose event of a
form.
I have copied from Northwind, for the sub OnClose
The If statement is all on one line, and it doesn’t need an ‘End if’.
My question is why isn’t the ‘End if’ needed, or why set the code this way
instead of the more common:
If then
End if
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If
End Function
Private Sub Form_Close()
If IsLoaded("frmViewTracks") Then DoCmd.Close acForm, "frmViewTracks"