I am trying to make an interface for my database. SQL Server 2008 express is used in my database. The compiler error prompted me an invalid outside source procedure. Here is the code.

Dim a As New adodb.connection
Dim b As New adodb.Recordset
Dim sqlStr As String ' String variable to store sql command

a.open _
        "Provider = sqloledb;" & _
        "Data Source={RJVC-F8C8F640BA\SQLEXPRESS};" & _
        "Initial Catalog={SMS_INQUIRY};" & _
        "User ID={};" & _
b.open "select * from Inquiry System", a, adopenkeys
MsgBox b(0)
Msgbox “Total no of records = ”& b.RecordCount

The code that you show needs to be within a procedure. Either a sub or function like form load, it cannot be in the general declarations section of a form or module.

Good Luck