if db.open = true then
db.close
End if

I want some code like this where it will check in the form load and if the connection is open , and if it is open it will close it..

To help us help you... we need a little more information. Are you using ADO, DAO, or RDO?

ado

You pretty much have it spot on in your first post swappy...
I use this code to check the connection state:

If oConnection.State = adStateOpen Then
        oConnection.Close
    End If

For info, oConnection was instantiated as ADODB.Connection beforehand.

Enjoy!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.