record not updating to the table

I am having issues with this code in VB6.  When i click the command button, the new record will show up in the datagrid but then it wont update to the table.  Do you see anything missing or wrong?

Private Sub Command7_Click()

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset

        If conn.State = adStateClosed Then
        conn.Open "Provider=sqloledb;Data Source=" & ConnectionIP & ",xxxxx;Network Library=DBMSSOCN;Initial Catalog= " & CAPDB & "; User ID=xxxx;Password=xxxxx"
        End If

esql = "select LinkageName, Linkage, AgreementDate from tblOrgMonthlyLinkages where Fiscal = " & Fiscal & " order by AgreementDate"

If rec.State = adStateOpen Then
End If

      rec.CursorType = adOpenStatic
      rec.CursorLocation = adUseClient
      rec.LockType = adLockOptimistic
      rec.Open esql, conn, , , adCmdText

        rec!LinkageName = Text3
        rec!Linkage = Text5
        rec!AgreementDate = DTPicker4
        Set DataGrid1.DataSource = rec

    If rec.RecordCount > 0 Then
    End If
        DataGrid1.Columns(0).Width = 2500
        DataGrid1.Columns(1).Width = 4500
        DataGrid1.Columns(2).Width = 1500

End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NerdsOfTechTechnology ScientistCommented:
It looks like you are closing the recordset before opening it, move this to around line 42

If rec.State = adStateOpen Then
End If

Open in new window

al4629740Author Commented:
I made the change you suggested, but it still does not save the record
al4629740Author Commented:
Looks like my issue was related to something outside the scope of my original question.  Thanks as I have it solved.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
al4629740Author Commented:
Issue out of the scope of my asked question
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.