Results 1 to 7 of 7

Thread: DataCombo box real time update

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Daventry, Northants, England
    Posts
    6

    Post

    Hello,
    I have a DataCombo box on a form which is retrieving it's items from a Command in my DataEnvironment. The data I am working with on the form is from a recordset I have created programatically using OpenDatabase and OpenRecordset with a SELECT. When adding a record I use the .AddNew and .Update methods on the recordset. My problem is I can not get the DataCombo box to display the updated information after an add or an edit. I have tried a .Requery on the Command in the DataEnvironment, I have tried a .Requery and a .Move(0) on the recordset I am using, I have tried a .ReFill and a .Refresh on the DataCombo box. I have also tried using an Adodc control as the DataSource for the DataCombo box and refreshing that but that did not work either and I would prefer not to have to use an Adodc control. So, fundamentally, I think I need to update the Command in the DataEnvironment which I presume will update the DataCombo. Any suggestions greatfully received.

    Thanks in advance.

    Tom

  2. #2
    Junior Member
    Join Date
    Nov 1999
    Posts
    16

    Post

    After you requery the recordset, reset RowSource property for your Combo Box:

    Set DataCombo.RowSource = DE

    Regards, Vlad

  3. #3
    Junior Member
    Join Date
    Nov 1999
    Posts
    16

    Post

    Tom,

    Can you post the code fragment?

    Vlad

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Don't waste your time with the data environment, just use the ADO objects. Execute a SQL statement to retrieve the fields and repopulate your combo box. The data environment can be finicky and unpredictable

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Daventry, Northants, England
    Posts
    6

    Post

    Vlad,
    Thanks for your reply, unfortunately this method seems to work in a delayed fashion. If I do an edit then the edit which I did does not appear in the DataCombo box until I do another edit and I can not find the command(s) which make this happen. Thanks very much for your help so far.

    Tom

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Daventry, Northants, England
    Posts
    6

    Post

    Hello both, thanks for your replies, OK here is a code snippet, I hope it is enough:-

    ' HERE I HAVE SET UP THE NEW RECORD USING
    ' COMMANDS SUCH AS
    ' customers!Name=Form2.CustName.Text
    ' AFTER DOING A customers.Edit or AddNew

    customers.Update
    customers.Move (0)
    Adodc1.Recordset.Requery
    Set DataCombo1.RowSource = Adodc1
    DataCombo1.ReFill
    DataCombo1.Refresh

    Using the Adodc certainly seems easier, however the changes only appear in the DataCombo box the next time I do an edit which results in the DataCombo box containing the last edit and the text box with the most recent edit...very strange! Thanks again for your help, any other suggestions would be great.

    Tom

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Daventry, Northants, England
    Posts
    6

    Post

    Hello, me again, I have just found out that if I exit the form and go back in then the DataCombo box updates, however, if I use Unload Form and then Form.Show it does not, could it be something to do with the way I have opened the database, caching or something????

    Thanks

    Tom

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