Message box when data is entered in a form

M

MSA

I have a data form that the users use to input data. Once all the fields are
filled in and "Enter" is hit. I would like to have a pop-up message box
appear confirming that the data is successfully entered in the Db as
acknowledgement. Could some one guide me how I can go about doing this,
thanks.
 
D

Douglas J. Steele

To know that it was succesfully added, put code in the form's AfterInsert
event. To know that it was successfully updated or added, put the code in
the form's AfterUpdate event.
 
D

Douglas J. Steele

First, are you sure you really want to do this? I know that I'd refuse to
use an application that insisted on interrupting me to present what's
realistically a useless bit of information. (The application's supposed to
write to the database: why tell me that it did what it was supposed to?)

If you're determined, my recommendation is to use VBA, not a macro.

That means that while in the form, select the Properties window and find the
AfterUpdate event for the form (make sure it's the form, not just one of the
controls on the form.)

Put [Event Procedure] as the value for the property, then click on the
ellipsis (...) to the right of the property. That'll take you into the VB
Editor, in the middle of code like:

Private Sub Form_AfterUpdate()

End Sub

Put the code to invoke the message box inside that, so that you end up with
something like:

Private Sub Form_AfterUpdate()

MsgBox "Data has been written to the database"

End Sub
 
N

Nicholas Scarpinato

I'd have to agree with Douglas... if I was the end user inputting data and I
had to click "OK" after every record I entered in order to go on to the next
entry, I'd want to strangle whoever programmed the thing that way. If you
absolutely have to have some kind of a message to let the user know the data
was successfully entered, I would suggest a hidden label on the entry form
that only becomes visible when a record is updated, and only stays visible
until the user begins a new entry. First, put a label on the form somewhere
where it will get the user's attention (I would suggest putting it at the
bottom like a status bar type message) and set it's Visible property to
False. Then put code something like this in the On Update section of the last
field on the form:

Private Sub Form_OnUpdate()
Me!LabelName.Visible = True
End Sub

And in the On Update section of the first field on the form, put this:

Private Sub Form_OnUpdate()
Me!LabelName.Visible = False
End Sub

That will cause the status message to display from the time the last record
was updated until the first field of a new record is updated. The user will
always see the message, but they won't have to stop to click out of it and
move on.


Douglas J. Steele said:
First, are you sure you really want to do this? I know that I'd refuse to
use an application that insisted on interrupting me to present what's
realistically a useless bit of information. (The application's supposed to
write to the database: why tell me that it did what it was supposed to?)

If you're determined, my recommendation is to use VBA, not a macro.

That means that while in the form, select the Properties window and find the
AfterUpdate event for the form (make sure it's the form, not just one of the
controls on the form.)

Put [Event Procedure] as the value for the property, then click on the
ellipsis (...) to the right of the property. That'll take you into the VB
Editor, in the middle of code like:

Private Sub Form_AfterUpdate()

End Sub

Put the code to invoke the message box inside that, so that you end up with
something like:

Private Sub Form_AfterUpdate()

MsgBox "Data has been written to the database"

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


MSA said:
Thanks for the input. But what code should I put in to make the msg box
pop up.
 
N

Nicholas Scarpinato

Slight error in my previous post... this should all be done in the
AfterUpdate section... OnUpdate doesn't exist. It's been a long day today.

Nicholas Scarpinato said:
I'd have to agree with Douglas... if I was the end user inputting data and I
had to click "OK" after every record I entered in order to go on to the next
entry, I'd want to strangle whoever programmed the thing that way. If you
absolutely have to have some kind of a message to let the user know the data
was successfully entered, I would suggest a hidden label on the entry form
that only becomes visible when a record is updated, and only stays visible
until the user begins a new entry. First, put a label on the form somewhere
where it will get the user's attention (I would suggest putting it at the
bottom like a status bar type message) and set it's Visible property to
False. Then put code something like this in the On Update section of the last
field on the form:

Private Sub Form_OnUpdate()
Me!LabelName.Visible = True
End Sub

And in the On Update section of the first field on the form, put this:

Private Sub Form_OnUpdate()
Me!LabelName.Visible = False
End Sub

That will cause the status message to display from the time the last record
was updated until the first field of a new record is updated. The user will
always see the message, but they won't have to stop to click out of it and
move on.


Douglas J. Steele said:
First, are you sure you really want to do this? I know that I'd refuse to
use an application that insisted on interrupting me to present what's
realistically a useless bit of information. (The application's supposed to
write to the database: why tell me that it did what it was supposed to?)

If you're determined, my recommendation is to use VBA, not a macro.

That means that while in the form, select the Properties window and find the
AfterUpdate event for the form (make sure it's the form, not just one of the
controls on the form.)

Put [Event Procedure] as the value for the property, then click on the
ellipsis (...) to the right of the property. That'll take you into the VB
Editor, in the middle of code like:

Private Sub Form_AfterUpdate()

End Sub

Put the code to invoke the message box inside that, so that you end up with
something like:

Private Sub Form_AfterUpdate()

MsgBox "Data has been written to the database"

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


MSA said:
Thanks for the input. But what code should I put in to make the msg box
pop up.

:

To know that it was succesfully added, put code in the form's AfterInsert
event. To know that it was successfully updated or added, put the code in
the form's AfterUpdate event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a data form that the users use to input data. Once all the fields
are
filled in and "Enter" is hit. I would like to have a pop-up message box
appear confirming that the data is successfully entered in the Db as
acknowledgement. Could some one guide me how I can go about doing this,
thanks.
 

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