If msgbox is yes then checkbox is checked?

E

Erin Freeman

Hi there

For some reason i cant get this code to work. On the "On Close" action of a
form, i want a checkbox to pop up to ask whether the data has been changed,
if the user chooses yes then i want my "revised" checkbox to populate with a
checkmark

'If MsgBox(" Have you revised this data?", vbYesNo) = vbYes Then
'Me.chkrevised = True

'End If

It doesnt seem to work, not sure what i am doing wrong. any help would be
greatly appreciated.

Thanks
 
M

Michael Stanbarger

I would suggest creating a small form for this instead of using a MsgBox
script. This way you can bind it to the table that has the field you want to
change.
 
E

Erin Freeman

not sure i follow you. the "revised: checkbox is currently on a form so when
the user tries to close the form, i should have a form pop up asking if they
have revised the data? i guess that makes sense... i will try that
 
E

Erin Freeman

Hi Michael,

So if i have a form that pops up when the main form is closed that asks if
the information has been revised, which works, however how do i get the popup
form to open to correct record, i have tried variaitions of code i could find
for filtering but for some reason i cant get it to work,
 
B

BruceM

Maybe this would work in the form's Before Update event:

If Not Me.NewRecord Then
Me.Updated = True
End If

This assumes there is a Yes/No field named Updated. The Before Update event
runs only if the record has been revised. If you prevent it from running
for a new record it will run only if an existing record is changed. If it
is revised again there will be no way of knowing that, but that is also the
case if you ask the user to check a box. If the box is already checked it
could cause confusion. With the automated code no user action is required.

Another option is to create a Date/Time field. I will call it DateUpdated.
In the form's Before Update event:

If Not Me.NewRecord Then
Me.DateUpdated = Now
End If

This will record when the record was last changed.
 
M

Mike Painter

Any change will be known by Access with the .dirty property.
You can just check the box without asking.
The only caveat is that *any* change marks the record dirty so if you change
"Fred" to "Bob" and then back to Fred it will trigger.
This can be beat by comparing the .previousvalue with the current value.
 

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

Similar Threads


Top