pop-up confirmation message when changing a record

le888 said:
She has wrote this :Originally Posted by Lala
thanks, but i was thinking doing it not field by field (because it'll be too much of a hastle to click yes on each field), but record by record

so my question is, where should i put the code for the message box to pop up after the user leaves the record?
Regards,
Le

That is the point Rich is making. If you have already left the record, what's the point in checking anything? You might as well build an audit process for the entire table(s) that runs independently of the data entry process.
 
Taff said:
Try this,

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & " Do you wish to save the changes?"

If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo

'For Access 95, use DoMenuItem instead
'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If

End Sub

Ant.



thank you

I got it to work somehow, but there's a little bug when saving the record
i'll post my code in a couple of days, maybe ya can tell me what's wrong

but it's working
the bug only shows up if the user saves by clicking YES and then keeps working on that same record

then he doesn't get the confirmation message
it just saves it

but i'll try it your way next time i'll go there
for now i left it like that

thank you very much

some people here are dorks and instead of helping, they waste space by trying to look cool

of course, that's easier than posting the PERFECT solution

but instead, people here like to post some code and a phrase like
"it's really simple, you should've found this in the help file"
and not even realize that they didn't understand what I asked for and their code is useless


anyway, thanks again
i'll definitely try it
it looks like what i need, and even if not, it's a start
i'm sure i'll be able to make it work
that was all i needed, a start
i'm not stupid, i don't need for you guys to write my programs
i'm actually pretty good at this
but sometimes i get stuck and don't even know how to approach something
that's when i come here
and even if i don't get a solution, i always get at least a direction from you guys, and that's enough
 
le888 said:
Hi,

I am not sure this will help. But if you have time take a look on it. I have copy some where on the net but I can find the hyperlink. I didn't try it.

'
Adding Simple Validation...
Making Sure the User Fills In All the Fields
A Function to Pinpoint Missing Data
Here is an example of how you can write a piece of "generic" code to check that the form has been filled in. You could, of course, set the Required property of each field to Yes but this method involves less work and gives you the opportunity to display a friendly message and take the user straight to the appropriate field.
In the same code module as the form's event procedures, create the following custom function. You can enter it after the last of the event procedures:



How the Function Works
The CheckData function returns False if it finds an empty text box or True if it does not (hence its declaration as Boolean). The first line sets the value of the function to True. It uses a For... Next loop to look in turn at each control on the form. If no empty controls are found the function returns the value True.
If it comes across an empty control an If Statement is invoked in which it notes the control's Caption (i.e. the Caption property of the label of a text box) and sets the value of the function to false. It then displays a message box incorporating the control's caption telling the user which control is missing data. Finally it sets the focus of the form to that control by placing the user's cursor into the control. At this point the function exits so that the user can correct their input.

Applying the Function
To make use of the function, add the line:

If CheckData = False Then Exit Sub

as the first line of each of the Click event procedures for the three tabs. When the user clicks one of the tabs, before anything else happens, the function is evaluated. If it returns True (meaning that there are no empty fields) the rest of the Click event procedure runs. If it returns False the Click event procedure exits (i.e. is cancelled) and the user is shown a message and taken to the appropriate field.

Hope this will help.

Le


thank you very much for taking the time out

but i need something little different

i don't care if they filled in all the fields
some fields can stay empty
this program is for an employment agency, it has about 50 fields and 3 subforms on each form, so they don't always get all the info right away, some info they fill in as they keep working with the candidate, months later

so that's not my concern

i want to make sure that when they mess up the record by accident
(and they do that all the time, because on top i have search boxes to quickly pull up records by name, last name, job title, and so on, and they keep typing their searches in the record fields, as opposed to the search fields)
they get a confimation message asking them if they want to save changes when they try to leave that record

because what happens now is that they mess up the record and go on and not even realize that they just deleted some info
users!!!!!!!!!!!!!
 
Taff said:
Try this,

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & " Do you wish to save the changes?"

If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo

'For Access 95, use DoMenuItem instead
'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If

End Sub

Ant.

THANK YOU!!!!!!!!!!!!!!!!!!!!
 

Users who are viewing this thread

Back
Top Bottom