Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a form which saves the data? 1

Status
Not open for further replies.

goodwork

Vendor
Joined
Feb 6, 2003
Messages
46
Location
GB

When I enter in a few fields (not all fields) and then click "close" - the table stores the data, including the blank fields!

I do not want this to happen. I want, when clicking close - lose all the information in the form. Any ideas how to do this?

Thanks so much in advance.

p.s. I know this must be somewhere in the forums - but I cannot find it....
 
'One way:

Private Sub Form_BeforeUpdate(Cancel As Integer)
' test all controls for null
If IsNull(Me.aaa) Or IsNull(Me.bbb) Or IsNull(Me.ccc) Then
Cancel = True
End If
End Sub

this will cause the form to never close unless all fields are entered.

alternately, you can say:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.aaa) Or IsNull(Me.bbb) Or IsNull(Me.TheName) Then
Me.Undo
End If
End Sub


to clear everything
 
thanks a lot

a star on the way
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top