What does "cancel as an interger" mean.

A

Allen Browne

Some of the built-in event procedures include Cancel as Integer in their
declaration.

If the procedure includes that, you are able to cancel the event. For
example, the Open event of the form has a Cancel argument, so you can cancel
the event (and stop the form from opening) by setting Cancel to true, e.g.:
Private Sub Form_Open(Cancel As Integer)
Cancel = True
MsgBox "You can no longer open this form."
End Sub

Cancel is intended as boolean (true or false). However, there was no such
data type when Access was first released, so the type is Integer for
historical reasons.
 
V

Van T. Dinh

Cancel is a variable (declared as Integer) used in some Events to pass a
value back to Access VBA for processing.

For an example, see Access VB Help on BeforeUpdate Event.
 
E

Edcontrengr

I am trying to make my form show the updated records after I run the "before
update event" is this possible.
 
E

Edcontrengr

I am trying to make my form show the updated records after I run the "before
update event" is this possible.
 
A

Allen Browne

Sorry: I don't undertand that question (or how it relates to your original
question.)
 
V

Van T. Dinh

I am not sure what you are trying to do???

Normally, the Form_BeforeUpdate Event occurs then the Record is updated then
the Form_AfterUpdate Event occurs. Before all of the happens, you Form
shows the data in the Form's buffer which is used in the update!
 
E

Edcontrengr

Following what you say. Is it possible for the data in the form buffer to
appear on the form before the info on the form is saved to the new record of
the table that is the record source for the form? Or in other words. Is it
possible to have what is in the buffer appear on the form before the record
is saved?
 
J

John Vinson

Following what you say. Is it possible for the data in the form buffer to
appear on the form before the info on the form is saved to the new record of
the table that is the record source for the form? Or in other words. Is it
possible to have what is in the buffer appear on the form before the record
is saved?

Ummm... yes. That's the default. You don't need ANY programming to see
the data which will be written to disk!

When you open a bound Form, and type data onto the screen, the form is
*itself* the "buffer". The data is not saved to the database until the
user takes some action to do so, such as moving to another record,
closing the form, or moving the focus to a subform.

It sounds like you're assuming that the data is taken from the form,
stashed somewhere else, and then written to the database. It's not.

The BeforeUpdate event can be used to check that the data currently on
the form is valid; you can refer to the form controls using syntax
like

If IsNull(Me!txtRequiredField) Then
MsgBox "Please fill in this required field", vbOKOnly
Cancel = True ' prevent the form data from being written to disk
Me!txtRequiredField.SetFocus
End If

If the value of the parameter Cancel is set to True, then nothing is
written to disk; if it's False (the default), then whatever is on the
form will be put into the table, and the form's AfterUpdate event will
fire.

John W. Vinson[MVP]
 
Top