Access 2000 Macros and VBA for data security and validation

D

D

Hello,
Firstly let me say I am not any kind of programmer and only have the
faintest understanding of programming However I am working my way
through creating an Access Database for use by a few users on a LAN. I
have reached a point where I thought I needed a macro to open a window
when a user changed data, asking them Yes to confirm it was correct or
a No for them to not save the changes if they had done it
inadvertently.
I found some VBA for doing this and was all set to put it in a Macro
but then I find that in Access 2000 writing Macros has been altered
into a kind of tabular arrangement where you pick various commands or
expressions and string them together in a table format to produce a
Macro, all be it in a different looking way to the indented code
subroutine way I was expecting. This made me think you could not use
code to do what I wanted and that I will have to learn the different
commands to use this tabular method. Then I read somewhere that you
can put code directly into the "beforeupdate" property for the Form. I
tried this but got a message saying I need to save the Macro first.
Now I am really confused because I cannot work out how to save this
code as a Macro in Access 2000 because when you got to design a Macro
this Tabular box thingy opens and invites you to use the individual
commands not a chunk of code. I am sure I must be being really thick
to you guys and will look back on this in fun when I get there, but
right now this bit seems as clear as mud.. Your help as always will be
most welcome, Regards,
David.
 
J

Joan Wild

If I understand you, you have some code that you'd like to put in the BeforeUpdate event property on a form. I don't think you want/need to use a macro at all.

Open the form in design view, and bring up the property sheet - Event tab. In the Before Update property, click on the dropdown and choose [Event Procedure]. Then click the build button (...) Paste your code between the following lines:

Private Sub Form_BeforeUpdate(Cancel As Integer)

End Sub
 
K

Keith Wilby

If I understand you, you have some code that you'd like to put in the
BeforeUpdate event property on a form. I don't think you want/need to use a
macro at all.

Open the form in design view, and bring up the property sheet - Event tab.
In the Before Update property, click on the dropdown and choose [Event
Procedure]. Then click the build button (...) Paste your code between the
following lines:

Private Sub Form_BeforeUpdate(Cancel As Integer)

End Sub


That code being along the lines of

If MsgBox("Save changes?",vbYesNo,"Confirm save") = vbNo Then
Cancel = True
Me.Undo
End If

HTH - Keith.
www.keithwilby.com
 

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