If form Contacts is open Close

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

Need VB code to perform this function.
If the form Contacts is open then close if not then do nothing.

Thanks,

Dave
 
I imported the utility from the Northwind db

If fisloaded("Contacts") = True Then
DoCmd.Close acForm, "Contacts"
End If

Else: DoCmd.Close

End If

End Sub
 
That Else: DoCmd.Close doesn't do anything, and you've got an superfluous
End If.
 
The northwind example has a differnt name. When you use function code, you
have to use the NAME THAT YOU give the function. In the northwind exmaple,
the fucntion is called

IsLoaded

not called

fIsLoaded

So, simply change your code to:

If IsLoaded("Contacts") = True then
DoCmd.Close acForm, "Contacts"
End If

The above code should work. So, just carefully check the name of the
function you copied. You can change the name of the function to whatever you
want, but then all code will have to match.

Also do a save and compile all, as this will check the names for you
*before* you try and run your code.
 
Back
Top