PDA

Click to See Complete Forum and Search --> : DataCombo box real time update


Tom Findlay
Jan 4th, 2000, 08:28 PM
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

vladimir
Jan 4th, 2000, 10:28 PM
After you requery the recordset, reset RowSource property for your Combo Box:

Set DataCombo.RowSource = DE

Regards, Vlad

vladimir
Jan 5th, 2000, 01:00 AM
Tom,

Can you post the code fragment?

Vlad

Clunietp
Jan 5th, 2000, 01:21 AM
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

Tom Findlay
Jan 5th, 2000, 11:50 AM
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

Tom Findlay
Jan 5th, 2000, 05:15 PM
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

Tom Findlay
Jan 6th, 2000, 04:56 PM
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