why the function connect is acceping constock as parameter ?? that is where the problem lies and the global variable becomes local inside connect.
'Public function connect(constock as ADODB.Connection)
'set constock = NEW ADODB.Connection
'with constock
'.ConnectionString="it's working fine"
'.Prov.
'.Open
'End with
'End function
Best Luck..
Nilesh