CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2000
    Posts
    66

    Why cannot enter EditMode?

    I build a ActiveX Control which called MyControl.ocx. It contains one Usercontrol
    named IntField which is used to receive integer input. It has a property Value. And
    I use menu Tools->Procedure Attributes set the Data Binding of property Value as
    "Property is data bound->This property binds to DataField & Updatae immediatly". So
    when I use this control I can set the DataSource and DataField of it. Now here comes
    the problem:

    When I add an ADO Data Control and assign it as the DataSource of my Control (call it
    IntField1) at the design time, then excute it. I can get the data from database and
    change freely. All the thing runs fine. But if I assign the ADO Data Control as the
    DataSource of IntField1 in my code (in the Form_Load Event for example). Only the first
    time I change the Value of IntField1 and call ADODC1.Recordset.Update can really update
    the database. After that, I cannot update database any more! I add some code in the
    IntField_Change() Event to check the ADODC1.Recordset Status (Debug.Print ADODC1.Recordset.EditMode)
    found that the first time when I change the value in IntField1, debug window said "1". after
    I clicked the Update button then change the value again, debug window always said "0". Means
    I cannot enter the EditMode any more.. Why? Is there missed something when I use Data binding?

    Please help me.



    //-----------------------------------------\\
    Where there's a wire , there's a way
    \\-----------------------------------------//

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Why cannot enter EditMode?

    a guess:
    You read the record first time. You change the value. The value of that field is changed but you do not requery. The field you changed is the key (or what you use to filter data), so the adodc is not able to find the "old" record...
    Try to force a requery (or a refresh) by code (ie: adodc1.refresh or similar)

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Dec 2000
    Posts
    66

    Re: Why cannot enter EditMode?

    Thanks. But if I put a TextBox on the form and assign the DataSource, DataField.
    All the setting will follow the former IntField1. You will find, you can change
    the TextBox any time, save any time, it will work. But the usercontrl IntField1
    will not. So, requery is not must be done.

    //-----------------------------------------\\
    Where there's a wire , there's a way
    \\-----------------------------------------//

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured