Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Editing a record

kg4ibjkg4ibj Member Posts: 7
I have successfully connected to my database with ADO. I can add new records and save them. However, when I attempt to edit them I receive this error message "Run-time error 3705 Operation is not allowed when the object is open."

Private Sub cmdEdit_Click()
Adodc1.Recordset.Open
End Sub

If I use

Private Sub cmdEdit_Click()
Adodc1.Recordset.EditMode
End Sub

my error message is "Compile error: Invalid use of property"

What am I doing wrong?

Comments

  • MasterijnMasterijn Member Posts: 188
    : I have successfully connected to my database with ADO. I can add new records and save them. However, when I attempt to edit them I receive this error message "Run-time error 3705 Operation is not allowed when the object is open."
    :
    : Private Sub cmdEdit_Click()
    : Adodc1.Recordset.Open
    : End Sub
    :
    : If I use
    :
    : Private Sub cmdEdit_Click()
    : Adodc1.Recordset.EditMode
    : End Sub
    :
    : my error message is "Compile error: Invalid use of property"
    :
    : What am I doing wrong?
    :
    Hi!
    EditMode is a property, in your code it's not used like one (and you don't need it in this case).
    Just change your field.value and call Recordset.Update
    There is a sdk specially for mdac (ado) at www.microsoft.com/data it contains all the docs you'll need.


  • GideonOmegaGideonOmega Member Posts: 617
    : : I have successfully connected to my database with ADO. I can add new records and save them. However, when I attempt to edit them I receive this error message "Run-time error 3705 Operation is not allowed when the object is open."
    : :
    : : Private Sub cmdEdit_Click()
    : : Adodc1.Recordset.Open
    : : End Sub
    : :
    : : If I use
    : :
    : : Private Sub cmdEdit_Click()
    : : Adodc1.Recordset.EditMode
    : : End Sub
    : :
    : : my error message is "Compile error: Invalid use of property"
    : :
    : : What am I doing wrong?
    : :
    : Hi!
    : EditMode is a property, in your code it's not used like one (and you don't need it in this case).
    : Just change your field.value and call Recordset.Update
    : There is a sdk specially for mdac (ado) at www.microsoft.com/data it contains all the docs you'll need.
    :
    :
    :
    You can also use the ADO command object to modify fields, you need to have a Open connection object for this to work - in this example g_objConn.
    [code]
    dim g_objCom as ADODB.Command

    set g_objCom = new ADODB.Command
    With g_objCom
    .ActiveConnection = g_objConn
    .CommandText = "Update tblname set fldname = value where fldname = whatever"
    .execute
    end with

    [/code]
    command objects are used for update's, iserts, and deletes.
    They also contain a parameters collection used to send and recieve data into stored procedures(such as with sql server).


    [blue]
    C:Dos
    C:Dos Run
    Run Dos Run
    [/blue]

  • kg4ibjkg4ibj Member Posts: 7
    : : : I have successfully connected to my database with ADO. I can add new records and save them. However, when I attempt to edit them I receive this error message "Run-time error 3705 Operation is not allowed when the object is open."
    : : :
    : : : Private Sub cmdEdit_Click()
    : : : Adodc1.Recordset.Open
    : : : End Sub
    : : :
    : : : If I use
    : : :
    : : : Private Sub cmdEdit_Click()
    : : : Adodc1.Recordset.EditMode
    : : : End Sub
    : : :
    : : : my error message is "Compile error: Invalid use of property"
    : : :
    : : : What am I doing wrong?
    : : :
    : : Hi!
    : : EditMode is a property, in your code it's not used like one (and you don't need it in this case).
    : : Just change your field.value and call Recordset.Update
    : : There is a sdk specially for mdac (ado) at www.microsoft.com/data it contains all the docs you'll need.
    : :
    : :
    : :
    : You can also use the ADO command object to modify fields, you need to have a Open connection object for this to work - in this example g_objConn.
    : [code]
    : dim g_objCom as ADODB.Command
    :
    : set g_objCom = new ADODB.Command
    : With g_objCom
    : .ActiveConnection = g_objConn
    : .CommandText = "Update tblname set fldname = value where fldname = whatever"
    : .execute
    : end with
    :
    : [/code]
    : command objects are used for update's, iserts, and deletes.
    : They also contain a parameters collection used to send and recieve data into stored procedures(such as with sql server).
    :
    :
    : [blue]
    : C:Dos
    : C:Dos Run
    : Run Dos Run
    : [/blue]
    :
    :

Sign In or Register to comment.