adp/sql2k data updatability with a bound form

R

Rob

Basics: I have a form which is bound to a stored
procedure with input/output parameters. I have set the
recordset property to the ADO recordset I am retrieving
in code. I want to be able to update the data on the
screen and prompt the user to save the changes with an OK
button. If data has changed (dirty) a yes/no msgbox
appears --If yes-commit and close. If no, rollback and
return to screen. (The data is not refreshed at this
point). If the user clicks CANCEL, same yes/no msgbox
appears. If yes--rollback and close the screen, If no--
return to screen and continue. Any sample code would be
greatly appreciated!

Rob
 
V

Vadim Rapp

R> Basics: I have a form which is bound to a stored
R> procedure with input/output parameters. I have
R> set the recordset property to the ADO recordset I
R> am retrieving in code.

don't do that. Specify recordsource for the form and let it build the recordset
itself.

R> I want to be able to
R> update the data on the screen and prompt the user
R>
R> to save the changes with an OK button. If data
R> has changed (dirty) a
R> yes/no msgbox appears --If
R> yes-commit and close. If no, rollback and
R> return
R> to screen.

sub cmdOK_click
docmd.runcommand saverecord
end sub
sub cmdCancel_click
if msgbox("cancel changes?)=vbyes then undo
end sub
sub beforeupdate (cancel as boolean)
cancel=(msgbox("update data?")=vbno)
end sub


I didn't test this code, it's just a sample.

Note that rollback is implemented not in cmdOK_click - that's because Access
will try to commit the changes if the user closes the form, or navigates to
another record, and some other events. This way, you intercept them all.

Vadim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top