By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,589 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,589 IT Pros & Developers. It's quick & easy.

msgbox to confirm update or insert?

P: n/a
Hi.

How does one display a confirmation message of either 'Record Updated' or
'Recorded Added"?
I've tried the form afterupdate and afterinsert but the afterupdate occurs
on an insert too?
So I tried to test for a new record in afterupdate using .newrecord but that
does not work.
Here is my code Any idea. Thanks in advance...

Private Sub Form_AfterInsert()
MsgBox "This Order was Added.", vbInformation, "Confirmation"
End Sub

Private Sub Form_AfterUpdate()
If Me.Form.NewRecord = True Then
Else
MsgBox "This Order was Updated.", vbInformation, "Confirmation"
End If
End Sub

Fred
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Have a "form level" variable that you set earlier, while you can still tell if this is a
new record. Use the value of this variable in the form's AfterUpdate event to give the
response you want. To Dim a form level variable, place the Dim statement in the
Declarations section of the form's code (where the Option Compare Database and Option
Explicit are).

--
Wayne Morgan
Microsoft Access MVP
"Fred" <fg***************@yahoo.com> wrote in message
news:bp*************@ID-76446.news.uni-berlin.de...
Hi.

How does one display a confirmation message of either 'Record Updated' or
'Recorded Added"?
I've tried the form afterupdate and afterinsert but the afterupdate occurs
on an insert too?
So I tried to test for a new record in afterupdate using .newrecord but that
does not work.
Here is my code Any idea. Thanks in advance...

Private Sub Form_AfterInsert()
MsgBox "This Order was Added.", vbInformation, "Confirmation"
End Sub

Private Sub Form_AfterUpdate()
If Me.Form.NewRecord = True Then
Else
MsgBox "This Order was Updated.", vbInformation, "Confirmation"
End If
End Sub

Fred

Nov 12 '05 #2

P: n/a
Hi.
Thanks. I've trying it, but what event should I put the test for new rec in?
I have this in beforeinsert but the value remains at -1 and here is my
declaration...

Option Compare Database
'' Next is to save if this is a new rec to display
'' correct confirmation msg in afterupdate event.
Dim IsNewRec As Integer
IsNewRec = 0
BeforeInsert event
IsNewRec = Me.NewRecord
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:ZK*******************@newssvr31.news.prodigy. com...
Have a "form level" variable that you set earlier, while you can still tell if this is a new record. Use the value of this variable in the form's AfterUpdate event to give the response you want. To Dim a form level variable, place the Dim statement in the Declarations section of the form's code (where the Option Compare Database and Option Explicit are).

--
Wayne Morgan
Microsoft Access MVP
"Fred" <fg***************@yahoo.com> wrote in message
news:bp*************@ID-76446.news.uni-berlin.de...
Hi.

How does one display a confirmation message of either 'Record Updated' or 'Recorded Added"?
I've tried the form afterupdate and afterinsert but the afterupdate occurs on an insert too?
So I tried to test for a new record in afterupdate using .newrecord but that does not work.
Here is my code Any idea. Thanks in advance...

Private Sub Form_AfterInsert()
MsgBox "This Order was Added.", vbInformation, "Confirmation"
End Sub

Private Sub Form_AfterUpdate()
If Me.Form.NewRecord = True Then
Else
MsgBox "This Order was Updated.", vbInformation, "Confirmation"
End If
End Sub

Fred


Nov 12 '05 #3

P: n/a
Option Compare Database
Option Explicit
Dim IsNew As Integer

Private Sub Form_AfterUpdate()
If IsNew = 1 Then
MsgBox "New"
Else
MsgBox "Update"
End If
End Sub

Private Sub Form_BeforeInsert(Cancel As Integer)
IsNew = 1
End Sub

Private Sub Form_Current()
IsNew = 0
End Sub

Phil

"Fred" <fg***************@yahoo.com> wrote in message
news:bp*************@ID-76446.news.uni-berlin.de...
Hi.
Thanks. I've trying it, but what event should I put the test for new rec in? I have this in beforeinsert but the value remains at -1 and here is my
declaration...

Option Compare Database
'' Next is to save if this is a new rec to display
'' correct confirmation msg in afterupdate event.
Dim IsNewRec As Integer
IsNewRec = 0
BeforeInsert event
IsNewRec = Me.NewRecord
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:ZK*******************@newssvr31.news.prodigy. com...
Have a "form level" variable that you set earlier, while you can still tell if this is a
new record. Use the value of this variable in the form's AfterUpdate event to give the
response you want. To Dim a form level variable, place the Dim statement in the
Declarations section of the form's code (where the Option Compare

Database and Option
Explicit are).

--
Wayne Morgan
Microsoft Access MVP
"Fred" <fg***************@yahoo.com> wrote in message
news:bp*************@ID-76446.news.uni-berlin.de...
Hi.

How does one display a confirmation message of either 'Record Updated'
or 'Recorded Added"?
I've tried the form afterupdate and afterinsert but the afterupdate occurs on an insert too?
So I tried to test for a new record in afterupdate using .newrecord
but that does not work.
Here is my code Any idea. Thanks in advance...

Private Sub Form_AfterInsert()
MsgBox "This Order was Added.", vbInformation, "Confirmation"
End Sub

Private Sub Form_AfterUpdate()
If Me.Form.NewRecord = True Then
Else
MsgBox "This Order was Updated.", vbInformation, "Confirmation"
End If
End Sub

Fred



Nov 12 '05 #4

P: n/a
Hi.

I found this works too. Thanks!
Option Compare Database
'' Next is used to save value for correct confirmaton message.
Dim IsNewRec As Integer
Private Sub Form_Current()
' set newrec switch for confirmation.
If Me.NewRecord Then
IsNewRec = 1
Else
IsNewRec = 0
End If
End Sub

Private Sub Form_AfterUpdate()
' Display confirmation Message.
If IsNewRec = 1 Then
MsgBox "Order Added.", vbInformation, "Confirmation"
Else
MsgBox "Order Updated.", vbInformation, "Confirmation"
End If
End Sub

"Phil Stanton" <ph**@stantonfamily.co.uk> wrote in message
news:3f*********************@mercury.nildram.net.. .
Option Compare Database
Option Explicit
Dim IsNew As Integer

Private Sub Form_AfterUpdate()
If IsNew = 1 Then
MsgBox "New"
Else
MsgBox "Update"
End If
End Sub

Private Sub Form_BeforeInsert(Cancel As Integer)
IsNew = 1
End Sub

Private Sub Form_Current()
IsNew = 0
End Sub

Phil

"Fred" <fg***************@yahoo.com> wrote in message
news:bp*************@ID-76446.news.uni-berlin.de...
Hi.
Thanks. I've trying it, but what event should I put the test for new rec

in?
I have this in beforeinsert but the value remains at -1 and here is my
declaration...

Option Compare Database
'' Next is to save if this is a new rec to display
'' correct confirmation msg in afterupdate event.
Dim IsNewRec As Integer
IsNewRec = 0
BeforeInsert event
IsNewRec = Me.NewRecord
"Wayne Morgan" <co***************************@hotmail.com> wrote in

message
news:ZK*******************@newssvr31.news.prodigy. com...
Have a "form level" variable that you set earlier, while you can still

tell if this is a
new record. Use the value of this variable in the form's AfterUpdate event
to give the
response you want. To Dim a form level variable, place the Dim

statement in the
Declarations section of the form's code (where the Option Compare Database
and Option
Explicit are).

--
Wayne Morgan
Microsoft Access MVP
"Fred" <fg***************@yahoo.com> wrote in message
news:bp*************@ID-76446.news.uni-berlin.de...
> Hi.
>
> How does one display a confirmation message of either 'Record

Updated' or
> 'Recorded Added"?
> I've tried the form afterupdate and afterinsert but the afterupdate

occurs
> on an insert too?
> So I tried to test for a new record in afterupdate using .newrecord

but
that
> does not work.
> Here is my code Any idea. Thanks in advance...
>
> Private Sub Form_AfterInsert()
> MsgBox "This Order was Added.", vbInformation, "Confirmation"
> End Sub
>
> Private Sub Form_AfterUpdate()
> If Me.Form.NewRecord = True Then
> Else
> MsgBox "This Order was Updated.", vbInformation, "Confirmation"
> End If
> End Sub
>
> Fred
>
>



Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.