Form_beforeUpdate question

  • Thread starter Thread starter Mark Andrews
  • Start date Start date
M

Mark Andrews

I have an Access2007 database that has many forms.

On each form I use the Form_BeforeUpdate event to check for required data
and if something if not filled in it display a msgbox and jumps to that
control so the user can fill in the value.
Example:
Private Sub Form_BeforeUpdate(cancel as Integer)
If IsNull(Me.Descrption) then
Msgbox "you must supply a description..."
Cancel = True
Me.Description.SetFocus
Exit Sub
end if
......more error checking etc...
End Sub


I also trap for the 2169 error.
private sub Form_error(DataErr as Integer, Response As Integer)

Select case DataErr
case 2169
Response = acDataErrContinue
case Else
response = acDataErrDisplay
end select
End Sub

For most forms:
When a user fills in some data but not ALL required data and then clicks the
upper right corner close button
the beforeUpdate event is called and then the form_error event stops that
"You can't save the record at this time..." error. ALL IS GOOD

On forms with graphs
the before_update event is getting called TWICE so my msgboxs are showing
twice before the form actually closes. It's kinda annoying.

Anyone know how to tweak

Mark
 
Yes I could, but I don't want to do that. I already have "save and close"
and "save and new" and those work fine. I'm trying to understand why the
beforeUpdate is called twice?

Any other help would be appreciated.
 
Hi Mark,

I do not know the answer to this issue. Perhaps someone else can help.

Although not related to this issue, I forgot to mention earlier that the
word Description is considered a reserved word. I recommend that you avoid
using any reserved words when assigning names to things within Access.

Problem names and reserved words in Access
http://allenbrowne.com/AppIssueBadWord.html



Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
Tom,

Thanks for the reserved word spot. Now I don't think it's entirely related
to graphs being on a form that the before_update is called twice. I have
about 10 forms and 4 of them had graphs and on those 4 I was seeing this
behavior. However just spotted it in another condition. If I try and trace
it with debugging it doesn't seem to call it twice. Turn off debugging and
back to twice using same testing senerio. Very weird.

Mark
 
Mark Andrews said:
I have an Access2007 database that has many forms.

On each form I use the Form_BeforeUpdate event to check for required data
and if something if not filled in it display a msgbox and jumps to that
control so the user can fill in the value.
Example:
Private Sub Form_BeforeUpdate(cancel as Integer)
If IsNull(Me.Descrption) then
Msgbox "you must supply a description..."
Cancel = True
Me.Description.SetFocus
Exit Sub
end if
......more error checking etc...
End Sub


I also trap for the 2169 error.
private sub Form_error(DataErr as Integer, Response As Integer)

Select case DataErr
case 2169
Response = acDataErrContinue
case Else
response = acDataErrDisplay
end select
End Sub

For most forms:
When a user fills in some data but not ALL required data and then clicks
the upper right corner close button
the beforeUpdate event is called and then the form_error event stops that
"You can't save the record at this time..." error. ALL IS GOOD

On forms with graphs
the before_update event is getting called TWICE so my msgboxs are showing
twice before the form actually closes. It's kinda annoying.

Anyone know how to tweak

Mark
 
Back
Top