Re: code to open blank form activates code to show record has changed
- From: Repent <repent34@xxxxxxxxxxx>
- Date: Wed, 20 May 2009 09:24:03 -0700
Dirk that worked well, thank you very much!!
chris
On Wed, 20 May 2009 11:36:48 -0400, "Dirk Goldgar"
<dg@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
"Repent" <repent34@xxxxxxxxxxx> wrote in message.
news:mm78159sd4l747o1ec1ksduettnbkd3c98@xxxxxxxxxx
I am trying to get this scenerio to work:
I have the code "DoCmd.GoToRecord , , acNewRec" in the onload event
for a form. it is supposed to open the form to a blank page. it does
open to a blank page, but when I start to make entries on the form,
the code to alert a user that the form is being changed activates. the
code to notify the user the form is being changed is in the "on dirty"
event of the form and is "Detail.BackColor = RGB(255, 100, 100)
InfoMessage.Caption = "You have modified this record. " & _
"If you move to another record, your changes will be applied. " & _
"To cancel your changes, hit the Esc key (top left of keyboard)."
the code to nofity a user that the form is being changed is only
supposed to run when a current record is being changed, not when a
blank record is being changed.
What can I do to have my forms open to a blank entry form but not run
the code that thinks I'm changing a record that already exists?
Place the relevant code in an If block that checks whether you're on a new
record or not. For example,
'----- start of code -----
Private Sub Form_Dirty(Cancel As Integer)
If Not Me.NewRecord Then
Me.Detail.BackColor = RGB(255, 100, 100)
Me.InfoMessage.Caption = "You have modified this record. " & _
"If you move to another record, your changes will be applied. "
& _
"To cancel your changes, hit the Esc key (top left of
keyboard)."
End If
End Sub
'----- end of code -----
- References:
- Prev by Date: Re: GoToControl macro action
- Next by Date: Re: Form/Subform
- Previous by thread: Re: code to open blank form activates code to show record has changed
- Next by thread: image box updating when records advance
- Index(es):
Relevant Pages
|