Re: code to open blank form activates code to show record has changed



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 -----
.



Relevant Pages

  • Re: code to open blank form activates code to show record has changed
    ... "To cancel your changes, hit the Esc key." ... Private Sub Form_Dirty ...
    (microsoft.public.access.forms)
  • Re: Macro to change character spacing
    ... > Cancel button respond to the Esc key, set its Cancel property to True. ... > is a string that should be converted to a number (data type Single), ... > Private Sub cmdOK_Click ...
    (microsoft.public.word.vba.beginners)
  • Re: Pressing Esc to make a form disappear
    ... You can use the .cancel property for that commandbutton. ... Private Sub CommandButton1_Click ... I'm drawing a blank on how to have Excel read an Esc key as a trigger ...
    (microsoft.public.excel.programming)
  • Re: cancel add new record
    ... Microsoft Access MVP ... Rather hit the Esc key to cancel the edit in the current field, ...
    (comp.databases.ms-access)
  • Using EXC to cancel when theres no cancel button?
    ... On a form with no "Cancel" option, I want to trap the ESC key so that it ... Private Sub Form_KeyPress ... I SWEAR I heard it laughing!!! ... There's no good candidate for a "Cancel" option. ...
    (microsoft.public.vb.general.discussion)