Preventing update of records

G

Guest

I have a form that shows the results of a query. The form may show multiple
records. I have an update button (which updates the record being shown and
closes the form) and a close button (which undoes any changes to the current
record and closes the form). The close button is a physical button on the
form, not the little 'x' box in the upper corner of the window.

Here's my question. Let's say there are two records returned by the query.
The user makes a change in the first record, then uses the built-in record
selector at the bottom of the form to select the second record, makes a
change in that record, realizes that the second record didn't need to change
and clicks the close button. Based on the way I have it set up, the second
record 'undoes' itself, but the first record is changed. I only want changes
to happen if the user clicks the update button no matter what. Any way to
make this work correctly (without DAO/ADO)?

I've tried creating my own record selector buttons, with code that undoes
the current record before moving to another record, and it works, but I don't
want to have both my own buttons and the built-in record selector (I want the
user to be able to know how many records were returned).... unless someone
knows a programmatic way to know how many records were returned (again,
without resorting to DAO/ADO)?

Thanks in advance!
 
S

SusanV

Perhaps there's a slicker way to accomplish this, but I usually handle it by
setting the form's record selectors property to no, then adding buttons for
Next and Previous, and in the on click events for those buttons, using
something similar to:

If Me.Dirty Then
If MsgBox("Save Change To Record?", vbYesNo, "Save Change") = vbNo
Then
Me.Undo
Else DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
End If
End If
 
S

SusanV

Nice - something I'm sure users would like to see, but I hadn't thought to
include.

Thanks Steve!

SusanV
 

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