Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changes in recordsets

Status
Not open for further replies.

Catrina

Programmer
Feb 11, 2000
70
US
I have a form's textboxes populated with data from 2 recordsets.

sSQL$ = "SELECT * From MASTER Where PAYEMP='" & FEmp$ & "'"
rsAccess.Open sSQL$, Access, adOpenKeyset, adLockOptimistic

sSQL$ = "SELECT * From Tax WHERE PAYEMP='" & FEmp$ & "'"
rsAccess2.Open sSQL$, Access, adOpenKeyset, adLockOptimistic

For A% = 0 To 14
Set text(A%).DataSource = rsAccess
Next A%

text(0).DataField = "PAYEMP"
text(1).DataField = "FSTNAME"
text(2).DataField = "LNAME"
text(3).DataField = "FlexField"
text(4).DataField = "ADDR"
text(5).DataField = "CITY"


For A% = 15 To 30
Set text(A%).DataSource = rsAccess2
Next A%
''etc


First problem, if a change has been made, it is not automatically saved when the program is closed. What do I need to do to apply the changed textbox to the database?

Next problem, if I attempt a change, then try to close the recordset, I get an error. I'm hoping the first question will solve this problem.

Thanks
Catrina [sig][/sig]
 
Catrina,

I assume your text boxes are linked to the underlying table's fields with a data control on the form. If this is the case, then you need to issue an .Edit and then an .Update for the data control's recordset. Depending on the locking you use, the lock will be set on one of these. A trappable error can occur on both of these methods if they fail. [sig][/sig]
 
Catrina,

Do you have a data control and the text boxes pointed at the fields you are trying to update? You need to issue an .Edit and an .Update for your data control. depending on which locking option you selected, a trappable error can occur on either of these methods. If you are doing this in code and not using the data control, this still applies to the updating of the recordset.

Remember- the text boxes are a like a buffer and the recordsets can be used to display the current record in the text boxes. Any changes you make in those boxes must be forced back to the table (via the recordset) by issuing the .Edit and .Update.

[sig][/sig]
 
Hi catrina, i can see that you are using ADOs here. Yes, please see that you have your text boxes bound to the data control and also see that all the constraints on the data are also met with. If you dont want to use data control then you may have to handle everything through code(which i prefer as it gives more control over the data). This could be the source of your problem. In ADOs by default the recordset is in edit mode so no need to give .edit and yes you need a .update to commit changes(please check it out). If you still have problems mail me at gantibabu@yahoo.com. all the best...vijay [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top