From: Maracay on
Hi Guys,

I am created a consult form, is linked to a query, but when the form is open
it shows a data already, I would like to have the form empty no data at all
and when the use call the record, shows it, another thing is that I want to
create a cancel command button and what I want to do is clear all data from
the form.

I will appreciate any help

From: Jack Leach dymondjack at hot mail dot on
If you want the user to only add records but NOT have the ability to go back
and edit them:

Open the form using the DoCmd.OpenForm method. For the Datamode argument,
use DataEntry.



If you want to still be able to navigate to existing records, then you need
to include a line of code in the Form_Open event:

DoCmd.GotoRecord , , acNewRecord


Either of these methods will show "no data" (actually, a blank form being
that you are on a new record).


To provide a Cancel button, use the Me.Undo method behind the code of the
button. This is the equivelant of Ctrl+Z or Esc. Providing the user has not
saved the record yet, all data entered would be erased, leaving a blank form
again.

It may happen that you want to prevent the user from saving until certain
fields are filled in. In this case, use the Before_Update event of the FORM
(not a control), and validate the current entry. Set Cancel=True if you want
to cancel the save:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim bFlag As Boolean
If Isnull(Me.Control1) Then bFlag = True
If Isnull(Me.Control2) Then bFlag = True
If Isnull(Me.Control3) Then bFlag = True
If bFlag = True Then
Cancel = True
MsgBox "Pease fill required data!"
End If
End Sub



hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Maracay" wrote:

> Hi Guys,
>
> I am created a consult form, is linked to a query, but when the form is open
> it shows a data already, I would like to have the form empty no data at all
> and when the use call the record, shows it, another thing is that I want to
> create a cancel command button and what I want to do is clear all data from
> the form.
>
> I will appreciate any help
>