-
VB6. I have a form with an ADO control. I want to have the user click on a button to update a value rather than having them do it in the TextBox bound to the field. (Reason: I want to 3 other fields when this field changes.)
Example: User clicks on button and an iNput box comes up. User enters the number 15 and hits OK. I take that value and do the following:
With B.adodc1.Recordset
.Fields("Extension") = sInput '15
.Fields("Notes") = "USERID changed Fields")
.Fields("Late") = True
.Update
End With
With the above example the recordset is updated. However, the form still shows the old values prior to the update. If the user moves to the next record and then back, it is updated.
I have found the following ways to correct:
#1.
.MoveNext
.MovePrevious
I don't like this because I then run into .EOF and .BOF issues that I have to compensate for.
#2.
.Save
I don't like this because I then have to do a .Find in order to return to the record.
Isn't there some way to do an .Update and refresh the screen without #1 or #2 above.
Thanks
-
Even though the database is updated when you do an ADODC.Update, the textboxes will still show the data from when they were first initialized. To update the textboxes, use the following code:
With B.adodc1.Recordset
.Fields("Extension") = sInput '15
.Fields("Notes") = "USERID changed Fields")
.Fields("Late") = True
.Update
End With
textfields1.text = B.adodc1.Recordset("Extension")
textfields2.text = B.adodc1.Recordset("Notes")
etc...
-
I think I found the solution. I update the textboxs rather than the ADO Field. When I do this, the screen changes imidiately. This has always worked until the user clicks on my exit button at which point it would not save the changes. I put a .Save just before the End statement and it takes care of the problem. Thanks
-
Yes, Update, But
I have the impression that entering test into a text box does not immediately update the underlying recordsource (Adodc). This happens only:
(1) when you click on another control,
(2) when the record on the underlying datasource us changed.
If a user updates a text box and then immediately quits the form or the application, then the last edit he made will be lost, since neither (1) nor (2) applies. I have lots of problems with this.
One possible solution is a Save button. However Access (for example) does not use such a save button. The user should not be bothered with our programming problems. Does one not always want to do a task with as few keystrokes as possible?
Another solution is to programmatically use (2). I have seen code in this forum like:
rs.Moveprevious
rs.Movenext
I prefer:
rs.Move 0
At least you will not bump into BOF or EOF. However I very often have a DataGrid on the form which is specific for each record of the Adodc and is reloaded using the Adodc_MoveComplete event. Any rs.Move used just to get the recordsource really updated, will trigger this event and cause useless overload loading.
I also have tried to use (1) programmatically:
me.Text1.SetFocus
However this does not do it. SetFocus does not seem to do precisely what happens when you click into another control.
I am sure you guys have an opinion on this.