if db.open = true then
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?

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
    End If

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