Close it in a module. You can use this code:
First move this line of code out of the function you created
Public myConnection As New OleDb.OleDbConnection
conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = D:\vb programs\working copy for windows application 4\WindowsApplication4\student.mdb"
myConnection = New OleDb.OleDbConnection(conString)
and your function will be re-coded like this:
Public Function DBconnection() As OleDbConnection
myConnection.Open()
Return myConnection
End Function
Public sub CloseOleDB()
Try
myConnection.close()
Catch ex as Exception
End Try
End Sub
You can then call CloseOleDB() within the form to close your connection.
Cheers!