If form Contacts is open Close

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
 
D

Dave Elliott

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
 
D

Douglas J. Steele

That Else: DoCmd.Close doesn't do anything, and you've got an superfluous
End If.
 
A

Albert D. Kallal

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.
 

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