0

Hello all,

I am having an issue with saving data entry from a vb6 form to a microsoft access 2003 form.

Can anyone please help? I am getting the error "Operation is not allowed when the object is closed."

I appreciate all your help!

Option Explicit
Dim cn As ADODB.Connection              ' Establishing a Connection Object that provides a connection to the data
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset

    ' Pass the connection string as the first argument to the Open method
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source= \\Hmstore\hmstore\Users\Esha\QST_Job_Request\QSTJOBS.mdb; Persist security info = False"

    cn.Open

    ' With recordset
    rs.MoveLast
    rs.AddNew
    rs(0) = Text3.Text
    rs(1) = Text4.Text
    rs(2) = Text7.Text
    rs(3) = Text5.Text
    rs(4) = Combo3.Text
    rs(5) = Text6.Text
    rs(6) = Text8.Text
    rs(7) = Text10.Text
    rs(8) = Text2(1).Text
    rs(9) = Combo1(1).Text
    rs(10) = Combo1(2).Text
    rs(11) = Combo1(3).Text
    rs(12) = Combo1(4).Text
    rs(13) = Combo1(5).Text
    rs(14) = Text2(0).Text
    rs(15) = Combo2(0).Text
    rs(16) = Combo2(1).Text
    rs(17) = Combo4(0).Text
    rs(18) = Combo4(1).Text
    rs(19) = Combo4(2).Text
    rs(20) = Combo2(2).Text
    rs(21) = Combo2(3).Text
    rs(22) = Text1.Text
    rs.Update

    ' Close the database.
    cn.Close
    Set cn = Nothing

' BELOW COMMENTED OUT----was not sure which was better
'    With rs
'        .MoveLast
'        .AddNew                            ' Adding new record and updating all the fields
'        .Fields("RequestorName") = Text3.Text
'        .Fields("Phone") = Text4.Text
'        .Fields("TestPurpose") = Text7.Text
'        .Fields("DateRequested") = Text5.Text
'        .Fields("Priority") = Combo3.Text
'        .Fields("DateNeeded") = Text6.Text
'        .Fields("DateCompleted") = Text8.Text
'        .Fields("CompletedBy") = Text10.Text
'        .Fields("Program") = Text2(1).Text
'        .Fields("HeadManufacturer") = Combo1(1).Text
'        .Fields("PreampVendor") = Combo1(2).Text
'        .Fields("PreampGeneration") = Combo1(3).Text
'        .Fields("Platform") = Combo1(4).Text
'        .Fields("HeadsInstalled") = Combo1(5).Text
'        .Fields("Quantity") = Text2(0).Text
'        .Fields("IniTest") = Combo2(0).Text
'        .Fields("IniTemp") = Combo2(1).Text
'        .Fields("HeadInit_A") = Combo4(0).Text
'        .Fields("HeadInit_B") = Combo4(1).Text
'        .Fields("HeadInit_C") = Combo4(2).Text
'        .Fields("ReTest") = Combo2(2).Text
'        .Fields("ReTemp") = Combo2(3).Text
'        .Fields("SpecialRequest") = Text1.Text
'        .Update
'    End With
2
Contributors
1
Reply
17
Views
3 Years
Discussion Span
Last Post by rishif2
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.