Access 2000 mdb and an option box for saving record

  • Thread starter Thread starter Rob S
  • Start date Start date
R

Rob S

Hi,

Firstly I'm a complete Access novice.

We have inherited a Access 2000 mdb with various names and addresses stored,
which we access through a form. I can let either everyone or no-one update the
database with file permissions, but what I want to be able to do is let everyone
make amendments, but have a Yes/No dialogue as they leave the record/quit the
database so they can save or discard their amendments to that record. Or failing
that an "update mode" button on the form which changes just that record from
read only to read/write.

This surely isn't that complicated, but we've struggled all afternoon on it. So
far we have come up with a macro associated with the BeforeUpdate event, which
pops up a warning MsgBox, but can't see anywhere to have a Yes/No box. Would we
need to get into VB for something as simple as this?

regards

-Rob
robatwork at mail dot com
 
In your form design view, go to the properties window, and, in the Event
tab, select [Event Procedure] for BeforeUpdate (make sure that the
properties window says "Form" in the title bar, so that you're modifing the
properties for the form). With the cursor in the BeforeUpdate line of the
properties window, click the ellipsis next to [Event Procedure]. You should
be brought into a window that looks something like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)


End Sub

Somewhere between the "Private Sub" and "End Sub" lines, insert the
following so that the window now looks like:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If MsgBox("Save changes made to this record?",
vbQuestion+vbYesNo)=vbNo then
Cancel = True
End If

End Sub

That should take care of it.

Neil
 
- If MsgBox("Save changes made to this record?",
-vbQuestion+vbYesNo)=vbNo then
- Cancel = True
- End If

Excellent Neil - just the trick. We amended it to do a form.Undo if the answer
was no, but many thanks for setting us on the right lines.

regards


-Rob
robatwork at mail dot com
 
Back
Top